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

I have a parse error, no parSeInt needed I believe, but still is the error always popping up

This is my program, I was tempted to add === for boolean, please help, var isAdmin = false; var isStudent = false;

if ( isAdmin ) { alert("Welcome administrator"); } else if (isStudent) { alert("Welcome student"); } else { (isAdmin=false||isStudent=false) alert("Who are you?");}

3 Answers

It should be coded this way instead. The reason you are getting an error message is because the else statement that you made for your last line of code is not meant for another condition to be met. The else statement is meant to go through if the previous conditions are not true. Since isAdmin and isStudent are already false, you would just need the alert message instead. I hope that helped!

var isAdmin = false; 
var isStudent = false;

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

I believe this is your program.

var isAdmin = false; 
var isStudent = false;

if ( isAdmin ) { 
  alert("Welcome administrator"); 
} else if (isStudent) { 
  alert("Welcome student"); 
} else { 
  (isAdmin=false||isStudent=false) alert("Who are you?");
}

The error is coming from you last else statement. If you are trying to check the condition of the code inside the parenthesis of your else statement, you'll need to change it to an else if statement and move the parentheses code outside your {...} Look at your existing else if statement for a reference.

Also, if that is what you are trying to do, you'll need to re-examine your use of the = operator. It seems you are trying to check for equality, however, a single = is an assignment operator. Try using === to check for equality.

I really like this reponse! I hope I can speak/write like this one day, once I'm more experienced at explaining concepts.

Thank you so much indeed, Thanks very much stephen you are perfectly right