What if choice 1 is paper?


#1

I can't seem to figure out this problem, it says it's an unexpected else, and it must be referring to else closest to the end of the code since before I added that different outcome (What if choice 1 is paper) it was working fine. It looks almost exactly the same as the first outcome, I feel it has something to do with semi-colons.

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

Having formatted your code properly, I see that you are missing a closing brace } after:

else {
      return "paper wins";
      }

and it looks like you have an extra brace on the second last line.


#3

Thanks, I was indeed missing a closing brace, didn't catch that one.