4. Computer Choice: Part 2


#1

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

When I press "Submit" I get this error: Oops, try again. There was a problem with your syntax.

I can't find the error. Thanks in advance.


#2

HI the else statement doesnìt take any condition

if (condition) {

}
else if (condition){

}
else {

}

#3

That did it =D Thanks!


#4

var userChoice = prompt("Voce escolhe pedra, papel ou tesoura?");
var computerChoice = Math.random();
if (computerChoice < 0.34) {
computerChoice = "pedra";
} else if(computerChoice <= 0.67) {
computerChoice = "papel";
} else {
computerChoice = "tesoura";
}