4. Computer Choice part 2: Please help


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

if (computerChoice <= 0.33) {
computerChoice = "rock";
else if (computerChoice <= 0.66 and > 0.33) {
computerChoice = "paper";
else if (computerChoice <= 1 and > 0.67) {
computerChoice = "scissors";

This is my code, but whenever i run it, it says Syntax Error: Unexpected identifier in the console and the codecademy prompt says that there is a problem with my syntax, but i cant find the problem.


I don't think javascript knows how to execute a condition using the word "and". There are characters that it would recognize, in the same way that you have used <= instead of writing "less than or equal to".


"and" isn't an identifier.

try (.33 < computerChoice <= .66).

The last 'else if' is not needed. You can just put:

else {
computerChoice = "scissors";

because there are no other options for the computer to choose.


try using && as and for example:

if (computerChoice>0 && computerChoice <.33)


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