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

Issue with JavaScript challenge

Taks: Add a Boolean value to the condition in this conditional statement. Use a boolean value that will result in the message "This is true" appearing in an alert box::

var myStatement = false;

if (myStatement) {
    alert('This is true');
} else {
    alert('This is false');
}

the alert box appears with the correct message but the task still fails. any ideas?

4 Answers

Use a boolean value that will result in the message "This is true" appearing in an alert box

umm ... your version of code would have "This is false" alert popup.

var myStatement = true;

Change myStatement to true if you want "This is true" to popup

Try double quotes...?

sorry, i was playing around with the variable and pasted the wrong thing in. the alert box appears with the first message, but the task still fails:

var myStatement = true;
if ( myStatement ) {
    alert("This is true");
} else {
    alert("This is false");
}

perhaps you should provide the link to the challenge here. Right now the code looks ok to me, but oftentimes the output that the challenge grader is looking for can be very strict, missing a full stop, has an extra space, wrong capitalization of a word ... can all cause the challenge fail to pass. So without actually taking a look at the challenge, there's no way to figure out why your code fail.

hi Phil Ward the exercise correct is : //you have to put true inside If//

var myStatement = true; if ( true ) { alert('This is true'); } else { alert('This is false'); }