I need help at step 7 please


#1

Please help, I can't figure out what i've done wrong. I'm getting the following error: SyntaxError: Unexpected token else

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

After the first else if you use else, then you use else if again. Else can not be followed by another else if.

You also have missed some closing brackets.


#3

Your else if statements should be following this pattern:

else if (condition){
if(condition){
return code ;
} else {
return code;
}
}

You did it correctly for else if(choice1==="scissors"). Can you see the error?


#4

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