Please help me, else error


So, I'm making a questionnaire for my Steam description website. I'm working with the new codecademy labs. Here's my code:

prompt("I am going to ask you some questions to get to know you. Ready?")

if ("Yes" == "Yes") {
confirm("Okay, let's go then!")
} elsif ("No" == "No");{
confirm("No? Then press Cancel");
} else ("Yes" == "No" and "No" == "Yes"){
confirm("Invalid answer. Press \"Cancel\" and try again.")

prompt("Where are you from?")
prompt("How old are you?")
prompt("Are you a coder/programmer?")

if ("Yes" == "Yes") {
confirm("Wow, really? Cool, I get to have one of my kind on my friends.")
} elsif ("No" == "No"){
confirm("That's okay, I just won't have you as one of my kin.")
} else ("Yes" == "No" and "No" == "Yes"){
confirm("Invalid answer. Press Cancel and try again.")


prompt("Next question. What do you do with your free time?")

confirm("You're done, send your answers to the creator of this website...and these questions.")

The only problem I seem to have is the else in the first if and else statement. Here's my error for that else:

SyntaxError: expected expression, got keyword 'else'

I don't know what's wrong. Please help me.


Putting a semicolon there is ending your if/else if/else statement. When the else is found further down it is unexpected and causes an error message to be displayed.

Something else to look at, the expression below is always going to be true -- I don't think that is what you had in mind?

if ("Yes" == "Yes")

edit: For more details, read @mtf's post. :slight_smile:


This looks like JavaScript, but also contains non-JS keywords; to wit: elsif.

The output of prompt() needs to be assigned to a variable or it simply vaporizes.

var user_input = prompt(" ... ");

Now we can test the input.

if (user_input == "yes") {


There should never be a semi-colon after the condition expression.

Not really sure what this is supposed to mean:

else is a default case that takes no conditional.

if ( ... ) {

else if ( ... ) {

} else {



Thank you very much. I probably didn't know what I was doing, so I asked you guys. I wanted to impress my friends on Steam by making the website more interactive, and you two helped very much! :smiley:


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.