Not acccepting {} but without the code works?


#1

If I take out the { } from the code it works fine. I am wondering if anyone can tell me why I get the unexpected token } response

 var userChoice = prompt("Do you chose rock, paper, or scissors?");
var computerChoice = Math.random();
if(computerChoice <= .33) {
    computerChoice = "rock";
    
}    else if(computerChoice <= .66) {
        computerChoice = "paper";
    
   } else(computerChoice <= 1) 
        computerChoice = "scissors";
        };

#2

@tagblaster02437,
The ELSE statement does not take a condition

A google search
if else if else site:developer.mozilla.org
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Control_flow_and_error_handling


#3

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