"Expected an identifier and instead saw 'else'"


#1


https://www.codecademy.com/courses/javascript-beginner-en-Bthev-mskY8/1/3?curriculum_id=506324b3a7dffd00020bf661#

At the last 'else if' statement, when you are supposed to make choice 1 === "paper", I get an error saying "Expected an identifier and instead saw 'else'" and "Missing ';' before statement". I sat here looking at my code for about 10 minutes, and have changed it numerous times to try to figure out what the problem is. I asterisked the line with the error below.

All help would be greatly appreciated!


var compare=function(choice1,choice2){
if(choice1 === choice2){
    return "The result is a tie!";
}
else if(choice1 === "rock");{
if(choice2 === "scissors"){
    return "rock wins";     }
else{
    return "paper wins";    }
                                }
**else if(choice1 === "paper");{**
if(choice2 === "rock"){
    return "paper wins";    }
else{
    return "scissors wins";}
}
};


#2

We don't put semicolons after we finish header of if/else if,

like one of the place you did this is here..

else if(choice1 === "rock");

There is one more, check that refine/eliminate it.


#3

Completely brainfarted! Thank you so much for pointing this out, I should've seen that XD


#4

Keep checking/revising the syntax . They are key elements of our programs.
:slight_smile:


#5

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