4/9 What's wrong with this code?


#1

I'm getting Syntax Error: Unexpected Identifier. Please help, thanks.

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 = "scissors";
}
console.log(computerChoice)


#2

You forgot the () around your conditions here:

if computerChoice <= 0.33 {

and here:

else if computerChoice <= 0.66 {

#3

first of all, conditions must include parentheses. Btw I stuck after I added parentheses...


#4

Of course! Thanks it worked.


#5

Thanks for reminding me about the parentheses. Did you figure out what was wrong with your code?


#6

Yep did this few days ago :smile: