Computer Choice: Part 2


#1


Computer Choice: Part 2


I'm not sure why I'm getting this error message => SyntaxError: Unexpected token <
Please need some help to move forward.


var userChoice = prompt("Do you choose rock, paper or scissors?");
var computerChoice = Math.random();

if (computerChoice =< 0.33) {
    computerChoice = "rock";
} else if (computerChoice =< 0.66) {
    computerChoice = "paper";
} else {
    computerChoice = "scissors";
}


#2

You have your equals sign the wrong way round. You need to put the equal (=) after the less than (<). Like this.

if (computerChoice <= 0.33) {
computerChoice = "rock";
} else if (computerChoice <= 0.66) {
computerChoice = "paper";
} else {
computerChoice = "scissors";
}

If that solved it please mark my reply as the solution.


#3

It worked! You're a genius :smiley:


#4

Haha na I wish. Thanks though.


#5

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