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 trialJoseph Harlow
Front End Web Development Techdegree Student 8,243 PointsCreate a conditional statement that tests if the isAdmin variable is true. If it's true, set the value of the message va
Please help. Stuck with this once.
const isAdmin = true;
const isStudent = false;
let message;
let isAdmin === true;
let message;
if (isAdmin) {
message = "Welcome admin".
}
3 Answers
joo
Python Development Techdegree Graduate 16,498 Points1- In your code, you're declaring the variable isAdmin twice, and you can't do that... And you can change the value only if used let instead of const, example:
let isAdmin = true;
isAdmin = false;
2- same for message variable, you can't name two variables the same! So the correct code should be:
const isAdmin = true;
const isStudent = false;
let message;
if (isAdmin) {
message = "Welcome admin";
}
3- Note: replace the dot with a semicolon in the if statement code block
Chinonso Umeanoikwa
Courses Plus Student 1,359 PointsChallenge Task 1 of 1 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;
please help me out guys
Daniel Coulter
4,691 PointsThanks Joo, I got similarly caught up, but I was thinking I needed to have it written as:
const isAdmin = true; const isStudent = false; let message;
if ( isAdmin ) { let message = "Welcome admin"; }
You helped me catch that I didnt need to "let" the message the second time. I only needed to redefine message.
Tim Oltman
7,730 PointsTim Oltman
7,730 PointsHi Joseph,
You basically have it. The isAdmin is already defined for you on the first line so you don't have to define it again using 'let'. Same with 'message'. The only thing you have to write is the if-statement.