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 trialJohn Cato
2,565 PointsAdd 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'); }
var x = True;
var y = False;
if ( x = True) {
alert('This is True');
} else {
alert('This is false');
}
<!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
Cissie Scurlock
11,072 PointsTry using === in your if statement. There's also inconsistency with the capitalization of true and false.
John Cato
2,565 PointsThank you, Cissie!
eck
43,038 PointsThe 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.