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 trialJonathan Grieve
Treehouse Moderator 91,253 PointsI'm not sure what this question is asking me. Where do I put the boolean?
I'm really not sure what this challenge is asking me to do.
It wants a boolean value in the empty condition statement. But as the videos have taught us we need an opening boolean value in order to give the condition statement an expression to evaluate
So I tend to try,
var message = true
if (message) {}
...etc
But the challenge won't have it. What am I missing?
message = true;
if (message) {
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>
1 Answer
Alex Heil
53,547 Pointshey Jonathan Grieve , from your code I see that you're actually on the right track. you set a variable to the boolean true and then pass it into the conditional.
however, the challenge is actually much more simple ;) it simply wants you to use the boolean directly, so no need to first create a variable and so on...
the code at the end would look like this:
if ( true ) {
alert('This is true');
} else {
alert('This is false');
}
hope that helps and have a nice day ;)
Jonathan Grieve
Treehouse Moderator 91,253 PointsJonathan Grieve
Treehouse Moderator 91,253 PointsWhen you put it like that, it makes so much sense! :)
And now when I read the question "boolean value" I see what it's asking for. I kept thinking the entire variable, so a name for the boolean.
Thanks for your help!! :)