Unexpected keyword "else"


#1

This is driving me nuts. Is this a bug or am I missing something simple? I refreshed the page and it worked on the previous try, now it does't.

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";
}
}


#2

It has something to do with the "else if" statement


#3

Remove the semicolon before your else if. It's ending your compare function before all the code necessary.


#4

I tried that already. I went all the way back and completely re-entered the code 3 times. Still not working


#5

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