Why does the computer show unexcpected token on this code?


#1

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

computerChoice = "rock";

};
else if (computerChoice >= 0.34 && computerChoice <= 0.66) {
computerChoice ="paper";
};
else (computerChoice >= 0.67) {
computerChoice = "scissors";
};


#2

closing curly brackets (}) of if, else if and else shouldn't have semi-colons

and else shouldn't have a condition since its everything else, giving a condition might result in not covering all cases


#3

thank you good man! I've been trying to solve this problem)


#4

Did you solve it now? That would be good :smiley:


#6

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