8. What is choice 1 is scissors? Syntax error


#1


The error message I keep receiving is: SyntaxError: missing ) after condition


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("Computer: " + computerChoice);

var compare = function(userChoice, computerChoice) {
    if (userChoice === computerChoice) {
        return "The result is a tie!"
    }
    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";
        }
    };
}
console.log(compare);


#2

Yes, you're indeed missing ) on your last else if condition below.

I hope this helps! :slight_smile:


#3

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