6/9 Syntax error?


#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";
}
}
What's wrong? I keep getting a syntax error message/


#2

I may be wrong, but you could be missing a closing bracket for your function.

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

I evened up the code for you and indented it so that you could see as well, the end bracket lines up with the beginning of the line for the if / else if statement.

In a perfect world you would have the last bracket there and no error messages.. But we live not in a perfect world.
:cry:


#3

Thank you for the help. But, I'm afraid I just have a token related error.