Seems like i did everything correct, but it gives me a syntax error


#1

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


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

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


#2

Remove this,

and this,


#3

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

if (computerChoice>=0 && <=0.33) { //here
    computerChoice="rock";
}
else if (computerChoice>=0.34 && <=0.66) { //here
    computerChoice="paper";
}
else {computerChoice="scissors";
}

In the two places I marked, the 'if' statements have errors. The first condition should be if (computerChoice>=0.34 && computerChoice <=0.33) {, and the second should be fixed in the same way. You need to put full conditions on both sides of &&.


#4

bandit is right.

The randomly generated number is automatically greater than zero, so you don't need >=0 in the first statement.
In the second, if the number is .33 or less, the if statement will be true, and won't go to the else if statement.

So, the and statements aren't needed in this case. For future cases, I thought you might want to know that your "&&" syntax is wrong. Check out this faq for more info.


#5

Thank you guys, the bandit was correct!


#6

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