What if choice 1 is paper assistance


#1



Please help. I am having a difficulty finding my error in the coding.


I keep getting a syntax error.


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

Check your else if
Syntax for if / else if / else should be like this:

if (condition1) {
    //something
} else if (condition2) {
    //something
} else {
    //something
}

JS glossary - CodeCademy


#3

You're missing a few brackets, don't forget when you're making a else/else if/if statement to take these with you " { } "
I'll post my code so you can see what I'm talking about, might be simpler.
Here's the correct code:

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

    }

};