6.What if choice1 is rock? - unexpected end of input?!?


#1



SyntaxError: Unexpected end of input

Hi, ive hd a look at this yesterday and a bit more today, I cant currnetly see how the code doesnt work, a some help s to why i am getting the error message would be appreciated, thank you,

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


results in : SyntaxError: Unexpected end of input

Thanks again


#2

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";
      }
   }
} // You need to close the function

#3

your function:

var compare = function (choice1, choice2) {

the { of your function has no matching closing }, add } at the right place


#4

thank you very much for your speedy solution!!


#5

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.