Computer Choice: Part 2 (SYNTAX ERROR)


Can someone please please help me with this? What's wrong in using the 'and' keyword in the if statement.?

I'm getting this error ---> SyntaxError: Unexpected identifier

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

Continuing the discussion from What is wrong with my code?!? Computer Choice part 2:


and is used in python, the and operator in javascript is: &&. This line:

else if(computerChoice>0.34 and computerChoice<0.66)

you use and, where you should use &&


Thanks a ton!!!! :smiley: Its working!! You explained it sooo well !