Understading the IF / ELSE IF / ELSE


I am not stuck on anything I just want to understand why during the if statements the code cannot look something simliar
like this

IF (computerChoice <= 0.33) ~ rock
ELSE IF (computerChoice <=0.66) ~ paper
ELSE (ComputerChoice <= 1) ~ scissors

I tried to narrow what the the limitation was for the random Math, but I don't understand why it would come up with
a syntax error instead of undefined number

Replace this line with your code. 
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.66 ) {
    computerChoice = "paper";
    } else {
    computerChoice= "scissors";


Just to put a close on this question...

else does not take a conditonal expression. It is the default branch.

if (condition) {}
else if (other_condition) {}
else {}

Be sure to add check spelling to your debugging check list.


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