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 trialAnsar Memon
8,991 PointsAdd an else if clause to see if Welcome student works
This challenge seems to be having some bug. Even though I am getting the alert box saying welcome student, it still gives an error saying it cant see the message
here is my code
var isAdmin = false;
var isStudent = true;
if ( isAdmin ) {
alert('Welcome administrator')
} else if ( isStudent === true ) {
alert('Welcome Student')
} else {
alert('Who are you?')
}
2 Answers
Raghav VC
Courses Plus Student 4,187 PointsHey there Ansar Memon . Your code looks fine. The syntax and the logic is perfect. But you made a small mistake in the printing. You should print "Welcome student" and not "Welcome Student". Since JS is case sensitive, you are getting this problem. Hope it helps (:
Luca Argenziano
16,416 PointsEhi Ansar, is much easier than it looks ;) You simply need to add the else-if code (as asked). No need for the additional else. I tried with this code and I passed:
else if ( isStudent ) {
alert('Welcome student')
}
Ansar Memon
8,991 PointsHi Luca,
Thanks for your response. It was a minor mistake since JS is case sensitive. I made it "Welcome Student" - "s" should have been be small caps.
Ansar Memon
8,991 PointsHi Luca,
Thanks for your response. It was a minor mistake since JS is case sensitive. I made it "Welcome Student" - "s" should have been be small caps.
Ansar Memon
8,991 PointsAnsar Memon
8,991 PointsThanks Raghav..good observation!