What if choice 1 is paper


#1

not sure where i went wrong here but please let me know if anyone sees my mistake. It worked for rock but getting syntax error for paper

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

your function:

var compare = function (choice1, choice2){

the { of your function doesn't have a matching } to mark the end of the function


#3

in which case (probably code blind)


#4

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

// ;)

Can you see it now?


#5

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

This is what i have and it still says syntax error


#6

what do you mean which case? normally when you have a function:

var example = function(){
  / function content
}

the } marks the end of the function, it is missing in your case, your last }:

 return "scissors wins";
    }
} // this one

marks the end of else if choice1 is paper, but you still need to close your function after it


#7

so simple but so necessary. Thanks you so much


#8