Need help with Rock Paper Scissors assignment Part 2


#1


https://www.codecademy.com/en/courses/javascript-beginner-en-6LzGd/2/4?curriculum_id=506324b3a7dffd00020bf661#

Can someone please help me figure out what's wrong with this code for building the Rock Paper Scissors game (Part 2)? It's now telling me "SyntaxError: Unexpected token else" . I've rewritten this code so many different ways and nothing seems to work! Please help! Thank you!


var userChoice = prompt("Do you choose rock, paper or scissors?");

var computerChoice = Math.random();
{
    if (computerChoice <= 0.33) {
        computerChoice = "rock";
}
    else if  (computerChoice <=0.67); {
        computerChoice = "paper";
}
    else {
    computerChoice = "scissors";
    }
};


console.log(computerChoice);


#2

Remove the semi-colon.

You also have your code wrapped in a block, which is unnecessary. It is not a function body. Just write the if statement,

if () {}
else if () {}
else {}

No punctuation on the structure, itself, only the statements contained within the individual blocks.


#3

Thank you very much! :slight_smile:


#4

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