What if choice1 is scissors?


#1

help
var userChoice = prompt("Do you choose rock, paper or scissors?");
var computerChoice = Math.random();
if (computerChoice < 0.34) {
computerChoice = "rock";
} else if(computerChoice <= 0.67) {
computerChoice = "paper";
} else {
computerChoice = "scissors";
} console.log(userChoice + computerChoice);

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

ERROR : problem with your syntax


#2

There are 2 issues. You have to decide if you want to complete your function with an else if statement or an else statement. Currently, you have both.

Second issue, does an else statement take a condition?