Why does the computer show unexcpected token on this code?


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

computerChoice = "rock";

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


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


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


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


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