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 JavaScript Basics (Retired) Making Decisions with Conditional Statements Add an Else If Clause

Ansar Memon
Ansar Memon
8,991 Points

Add 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

script.js
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

Hey 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 (:

Ansar Memon
Ansar Memon
8,991 Points

Thanks Raghav..good observation!

Luca Argenziano
Luca Argenziano
16,416 Points

Ehi 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
Ansar Memon
8,991 Points

Hi 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
Ansar Memon
8,991 Points

Hi 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.