What if choice1 is paper


#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";
}
if (choice1 === "paper") {
if (choice2 === "rock")
return "paper wins"}
else { return "scissors wins"
}

}
It says that my code returned 'paper wins' instead of 'scissors wins' when the inputs are paper and scissors. Please help


What if choice1 is paper?.... help im confuse here!
#2

It is not recommend to not use curly brackets for a if statement:

if (choice2 === "scissors") return "rock wins";

versus:

if (choice2 === "scissors") {return "rock wins";}

Now, you will see that your else:

else { return "paper wins";
 }

is not inside your else if (choice1 === "rock")