SyntaxError: Unexpected token {


#1

Why is this giving me this error? "SyntaxError: Unexpected token {"

var userChoice = prompt("Do you choose rock, paper or scissors?");
var computerChoice = Math.random();
console.log(computerChoice);
if (0<computerChoice<0.33) {
computerChoice = "rock";
} else if (0.34<computerChoice<0.66) {
computerChoice = "paper";
} else (0.67<computerChoice<1) {
computerChoice = "scissors";
}


#2

IS IN ELSE!

else{.....

for example:

var usuarioElige=prompt("¿Piedra, papel o tijera?");
computadoraElige=Math.random();

if (......){
......
}
else if (......){
.....
}
else{
....
}


#3

This is my code:

var usuarioElige=prompt("¿Piedra, papel o tijera?");
computadoraElige=Math.random();

if (computadoraElige>0 && computadoraElige<0,33){
console.log("Piedra");
}
else if (computadoraElige>0,34 && computadoraElige<0,66){
console.log("Papel");
}
else{
console.log("Tijera");
}

¡Espero te sirva!, Saludos.


#4

Its fine thanks you helped and fixed it, the else didnt need anything extra :slight_smile:


#5

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