SyntaxError: Unexpected identifier (HELP)


#1

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:

https://www.codecademy.com/courses/javascript-beginner-en-Bthev-mskY8/0/4?curriculum_id=506324b3a7dffd00020bf661#

This error pops up:

SyntaxError: Unexpected identifier

var userChoice = prompt("Question");

var computerChoice = Math.random(); 
    console.log(computerChoice);
    
    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?

Thanks,

Eddy


#2

else can't have a condition since its everything else


#3

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


#4

Just the else statement
}else{
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 ){
console.log("something");

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

}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:


#5

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)


#6

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