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 trialSHAWNELL HARRISON
16,282 PointsCan you please guide me in right direction?
Add a final else clause to this conditional statement. If both the isAdmin and isStudent variables are false, the value
const isAdmin = false;
const isStudent = false;
let message;
if ( isAdmin ) {
message = 'Welcome admin';
} else if ( isStudent ) {
message = 'Welcome student';
}
Steven Parker
231,236 PointsChallenges are very picky about outputs. It's not expecting to see the punctuation.
6 Answers
YerVonda Colbert
5,846 PointsThis is what I have and I keep getting cannot read property "1" null? Please help { } else { console.log = ("Access denied."); }
Steven Parker
231,236 PointsYou don't need to log anything, just update the "message" variable like the other conditions do.
YerVonda Colbert
5,846 PointsSteve:
Add a final else clause to this conditional statement. If both the isAdmin and isStudent variables are false, the value of the message variable should be "Access denied".
You ask me to remove punctuation. It till give me the same error.
} else { message = ('Access denied'); }
Steven Parker
231,236 PointsIt's not obvious from that snippet. Please show the entire code (use Markdown formatting to preserve the code's appearance).
YerVonda Colbert
5,846 PointsSteve: This the entire code:
Question: 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; cont guess = prompt('isAdmin true'); let correctGuess = True if (true) { console.log ("Welcome admin".) }
Steven Parker
231,236 PointsIs this the same challenge? This code is very different from what you originally asked about! It kind of looks like you mixed the code for this challenge with some from a different challenge.
This challenge doesn't use "prompt", and it doesn't "log" anything, and there's no guessing involved!
And please, when you post code, always use Markdown formatting to preserve the code's appearance.
YerVonda Colbert
5,846 PointsIs there anyway I can speak with you or is there another way I can get help. I have watch the Markdown formatting video twice. That'a not helping me show you what I am looking for. I only have 2 problems that I am working on to be done with the program. Please help or give me information to get in contact with some who can better help. Thanks
YerVonda Colbert
5,846 PointsI'm trying to send it the way you want. this not is launch but an objective?
Code
To install the latest version of NPM, you can type `npm install npm@latest -g
const isAdmin = false;
const isStudent = false;
let message;
if ( isAdmin ) {
message = 'Welcome admin';
} else if ( isStudent ) {
message = 'Welcome student';
} else isAdmin + isStudent = false
message= 'Access denied';
}
YerVonda Colbert
5,846 PointsQuestion to code: Add a final else clause to this conditional statement. If both the isAdmin and isStudent variables are false, the value of the message variable should be "Access denied".
I hope this is better steve
Steven Parker
231,236 PointsClose! But a final "else" does not need any kind of test. But it does need an open brace to start the code block and match the closing one at the end.
Steven Parker
231,236 PointsThe code you will add will look much like the "else if" section already provided, but a final "else" doesn't have a conditional expression.
Give it a shot and write again (showing the code you added) if you still have trouble.
YerVonda Colbert
5,846 PointsYerVonda Colbert
5,846 PointsI tried it this way too, and I keep getting the same message
} else { message = ("Access denied."); }