Where is the syntax error?


#1

var userChoice = prompt("Do you choose rock, paper or scissors?");
var computerChoice = Math.random();
if (computerChoice >= 0 && computerChoice <= .33) {
var computerChoice = "rock";
}
else if (computerChoice >= .34 && computerChoice <= .66) {
var computerChoice = "paper";
}
else (computerChoice >= .67 && computerChoice <= 1) {
var computerChoice = "scissors";
}

SyntaxError: Unexpected token {


#2

First try to put 0 infront of decimal numbers second else statement do not take any argument you can correct it by simply replacing it by if.


#3

by using the decimal point the 0 is implicitly set anyway still it is more obvious if you write it. The important factor is the of course the else.

@programmeranonymous Also about the var: You only need this when you use a variable for the first time not every time you change a value.