SyntaxError: Unexpected identifier (HELP)


Hello all,

First post!

I'm stuck on #4-Computer Choice: Part 2. I'm having syntax errors as I set up the computerChoice conditions for the rock, paper, scissors game. Here's the link:

This error pops up:

SyntaxError: Unexpected identifier

var userChoice = prompt("Question");

var computerChoice = Math.random(); 
    if (computerChoice < 0.34) {
    computerChoice = "rock";
    else if (computerChoice >= 0.34
    computerChoice < 0.66) {
    computerChoice = "paper"; 
    else (computerChoice > 0.67) {
    computerChoice = "scissors";

Can someone tell me what's wrong?




else can't have a condition since its everything else


So what does the "else" portion of the code look like?


Just the else statement
console.log("some text that indicates the user didn't use one of the preset answers. try again!");

If/ else if/ else statement
if( some parameter ){

}else if( some other parameter){
console.log("something else");

console.log("you didn't do either of the options, choose some parameter or some other parameter")

just a kind of example. hope this helps :smile:


the same as else always look:

else {


simply get rid of the condition, given else can't have a condition (how can it possible be everything else? If you give a condition, you might not cover all cases)


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