6/9 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";



it says there is an unexpected token else. I cant find it for the life of me. Please help. Cheers me ducks

  1. at if condition line ; semi-colon shouldn't be

2- one missing } at the last line


thanks bud, (over 20 characters)


In case you interested here is a post about what the semicolon after the condition does to your code:


Another common problem that doesn't apply to your code but did for mine seems to be that I closed my compare function before I wrote the else if statement, so that's the reason for the "unexpected else token." Your code should look something like this:

var compare = function (choice1, choice2) {
if (choice1 === choice2) {
return("The result is a tie!") }

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