Computer Choice Part 2


#1

Hi, I keep getting the error - SyntaxError: Unexpected token {
Cannot find the error for the life of me. Here is my code:

var userChoice = prompt("Do you choose rock, paper or scissors?")

var computerChoice = Math.random();
console.log (computerChoice);
if (computerChoice <= 0.33) {
console.log ("rock");
}
else if (computerChoice <= 0.66) {
console.log ("paper");
}
else (computerChoice > 0.67) {
console.log ("scissors");
}


#2

else does not have a condition. It is the default action. Remove.

Also, you need to set computerChoice = 'rock';, etc.


#3

Thankyou! it worked!


#4

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