Computer Choice part 2


var userChoice = prompt("Do you choose rock, paper or scissors?")

var computerChoice = Math.random()

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

Receiving a syntax error and not sure why...


What syntax error are you receiving?


else can't have a condition since its everything else.

Also, if you decide to use the and operator (&&) it would be better to do comparison at both sides of the and operator. You don't even need the and operator.


Thanks, it worked, what do you mean I don't need the and operator though? I fixed it to be (computerChoice > 0.34 && computerChoice < 0.66)


well, why do you need this condition:

computerChoice > 0.34

your if condition takes care of values lesser then .33, i don't see why you you need to repeat it else if. But that is just an optimization.


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