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

Boolean Challenge. Clueless

Create a conditional statement that tests if the isAdmin variable is true. If it's true, set the value of the message variable to "Welcome admin".

const isAdmin = true; const isStudent = false; let message; if (message === 'isAdmin' ) { console.log "Welcome admin"; }

2 Answers

While the advice from Curtis Reker is correct, that's not going to solve your problem because you aren't meeting the requirements of the challenge. It says to create a conditional statement to test if the isAdmin variable is true, but you are attempting to check whether or not isAdmin is equal to message. Even when you fix the quotes, this is going to evaluate to false because message is undefined and isAdmin is true. And when you fix that, the challenge is still going to fail because it says to set the value of the message variable to "Welcome admin", and you're not updating the message variable, you're just printing the output to the console (once you correct the issue with the parentheses).

Since it asks you to test if the isAdmin variable is true, put that in your if statement. I find it's easiest to put it in like you say it, adjusting the syntax to make the code correct. Then put in what's supposed to happen if the statement is true:

if (isAdmin === true) {
    message = "Welcome admin";

    //if you want to print it to the console, you can add:
    console.log(message);
}
Curtis Reker
seal-mask
.a{fill-rule:evenodd;}techdegree
Curtis Reker
Full Stack JavaScript Techdegree Student 4,607 Points

Remove the quote from message === isAdmin, when referencing a variable you can’t put quotes around the variable name.

Your console.log(); message is also missing the () around the β€œwelcome admin”