What If choice 1 is Paper? 4/7 SyntaxError: expected expression, got keyword 'else'


#1



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


I'm not exactly sure why this code won't go through. It says SyntaxEror: expected expression, got keyword 'else'.
I feel like I've closed everything but maybe there's a spelling error or something? I think I need a fresh pair of eyes because I'm going nuts. Anyone have any suggestions?


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

@valhallah

You forgot to close your else if statement with curly brackets


#3

Thank you for your reply! I'm not exactly sure what you mean. Could you show me where exactly in the code I'm missing a bracket?


#4

@valhallah

The part where you test if choice1 is equal to "rock". Between these line:

and this one:

You didn't close your else if statement that is wrapping the if-else statement. You also forgot to close your compare function with a curly bracket and semicolon


#5

---- Thanks so much! ----