Computer Choice Part 2: Syntax Error: Unexpected Token }


#1


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

Can someone help, please, and take a look at my code? I keep getting a syntax error, unexpected token }

Thanks!


var userChoice = prompt ("Do you choose rock, paper or scissors?");
var computerChoice = Math.random()
console.log(computerChoice) // not necessary for the game, just looking at how Math//.random works
if (computerChoice < 0.34) {
    computerChoice = "rock";
}
else if (computerChoice >= 0.34 && computerChoice <= 0.66) {
    computerChoice = "paper";
}
    else (computerChoice >= 0.67 && computerChoice <=1) {
        computerChoice = "scissors";
}


#2

This line should have a semi colon ; at the end.

And,

Seperate your else if statement. so that you check the computerChoice's seperately like so,

else if (computerChoice <= 0.67) {
    computerChoice = "paper";
} else {
    computerChoice = "scissors";
}
console.log(computerChoice)

And as you can see I print out computerChoice after everything.


#3

Oh! That looks so much nicer. Thank you for the assist!


#4

Your welcome! feel free to click the solution button if you feel that was the answer you were looking for. :smiley:


#5

Done! And it was. :smiley: