Computer Choice: Part 2 (SYNTAX ERROR)


#1



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

https://www.codecademy.com/courses/javascript-beginner-en-Bthev-mskY8/0/4?curriculum_id=506324b3a7dffd00020bf661#


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


var userChoice = prompt("Do you choose rock, paper or scissors?")
var computerChoice = Math.random()
console.log(computerChoice)
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:


#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 &&


#3

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