Why syntax error unexpected token {


#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.66) {
computerChoice="paper";
} else (computerChoice<=1) {
computerChoice="scissors";
}

`


#2

else can't have a condition since it is everything else.


#3

also you dont to need to write

computerChoice<=1

because Math.random() returns a random number between 0 (inclusive) and 1 (exclusive).


#4

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