SyntaxError: expected expression, got '<='


#1


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


I keep getting the following syntax error - SyntaxError: expected expression, got '<='.
Am I doing something wrong - why won't it recognize the <= ?


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.34 && <= 0.66) {
    computerChoice = "paper";
}
else {
    computerChoice = "scissors";
}
console.log(computerChoice);


#2

you don't need to use the and (&&) operator, since numbers smaller then .34 will let the if clause run, if the if clause runs, else if will never run, so you only need to check if computerChoice equals or is smaller then .66


#3

Legend. It worked. Thanks for the help. Learned something new about the If statements.


#4

and you do want to use the the and operator && you should do comparison at both sides:

else if (computerChoice >= 0.34 && computerChoice <= 0.66)

you have two check two conditions.


#5

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