Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript JavaScript Basics (Retired) Making Decisions with Conditional Statements Booleans

John Cato
John Cato
2,565 Points

Add a Boolean value to the condition in this conditional statement. Use a boolean value that will result in the message

Trying to understand why this code isn't working.

var x = True; var y = False; if ( x = True) { alert('This is True'); } else { alert('This is false'); }

script.js
var x = True;
var y = False;
if ( x = True) {
    alert('This is True');
} else {
    alert('This is false');
}
index.html
<!DOCTYPE HTML>
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <title>JavaScript Basics</title>
</head>
<body>
<script src="script.js"></script>
</body>
</html>

3 Answers

Try using === in your if statement. There's also inconsistency with the capitalization of true and false.

John Cato
John Cato
2,565 Points

Thank you, Cissie!

The boolean values for true and false should not be capitalized. I think this is why you are not getting your desired results.

Programming languages can be very sensitive. In JavaScript, punctuation and capitalization are very important and can be the difference between code that works or code that breaks.