I keep getting this error and I just need the right guidance.. SyntaxError: Unexpected token else


#1

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

};
console.log(compare);


#2

your if and else:

if (choice2 === "scissors") {
        return "rock wins";
    } else {
    return "paper wins";
}

should be nested inside the the else if:

else if (choice1 === "rock") {
    /* if and else here */
   }

same for else if choice1 equals paper


#3

Thanks. I got the program to run successfully. The only other problem I have now is it will not pick a winner. But after doing some searching on Google I think I may have found out what I need to do in order to get it working correctly.


#4

You still need to write that code in later exercises, but of course you can also do a google search


#5

yeah I made note of it. Thanks again :ok_hand: