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

Code is correct but why is it failing

Add a final else clause to this conditional statement so that if the isAdmin variable and isStudent variables are both false an alert opens with the message "Who are you?"

var isAdmin = false; var isStudent = false;

if ( isAdmin ) { alert('Welcome administrator'); } else if (isStudent) { alert('Welcome student'); } else { alert('Who are you'); }

this is the code if I preview it ti works but when I click check work it fails. this is in the tech degree full stack javascript.

2 Answers

Treehouse challenges are quite picky, not only does your code need to function correctly but all variables names and print statements needs to be exactly what the challenge asks for.

The problem with your code is that you are printing the statement "Who are you" rather than "Who are you?" which the challenge is expecting.

Adding that question mark in the string should make the challenge succeed.

Ok thanks I did not notice that.