What ifchoice1 is rock?


#1

Help! I can't seem to get it right.. I checked all, (including spelling he,he) still showes "syntax error".

var compare = function (choice1, choice2){
if( choice1 === choice2) {
return "The result is a tie!";
}
else if(choice1 === "rock"){
if(choice1 === "scissors"){
return "rock wins";
}else{
return "paper wins";
}
}
Either I am blind or stupid


#2

You are missing one } to close your function.

var compare = function(choice1, choice2) {
  if (choice1 === choice2) {
    return "The result is a tie!";
  } else if (choice1 === "rock") {
    if (choice1 === "scissors") {
      return "rock wins";
    } else {
      return "paper wins";
    }
  }
}

Here you go, it's fixed.


#3

Still not going through


#4

I have refreshed, and now it works, thanks a lot!


#5

No problem, glad it worked and glad you had one small misstype rather than logical error.