Help! Error: missing ) after condition


#1

var userChoice = prompt ("Do you choose rock, paper, or scissors?");
var computerChoice = Math.random();
console.log (computerChoice);
if (computer choice <= 0.33)
{
computerChoice = "rock";
}
else if ( computerChoice >= 0.67 )
{ computerChoice = "scissors";
}
else
{ computerChoice = "paper";
}

the above is my code. I have been checking my conditions and parentheses and I can't seem to find the syntax error.


#2

I don't see any mistake...

Try to cut/paste your console.log() after your else{...} since you want 'rock' or 'paper' or 'scissors' to be displayed, not number.


#3

here:

if (computer choice <= 0.33)

computer and choice are treated as 2 variables so the interpreter expects some kind of connection or at least a ) which tells it that the condition of the if is finished. Just use computerChoice instead and you should be fine.


#4

i used computerChoice all through but the error keeps occurring.


#5

else if(computerChoice <= 0.67) I think this one works, try using less than instead of greater than.

also i think if it is >=0.67 computerChoice will never end up in selecting paper


#6

He/She switched the cases >=0.67 would normally be covered by the else and assigns "scissors" which it does here too. So the part <=0.67 that normally assigns "paper" is now covered by the else and does as well what it is supposed to do. So the order might be confusing as it's not what it is covered in the instructions or freely seen but it still works as it follows the same logic.