Lesson 4 Part 2. SyntaxError: Unexpected token else


#1

var userChoice = prompt("Do you choose rock, paper or scissors?");
var computerChoice = Math.random();
console.log(computerChoice);
if (computerChoice < 0.33) {
computerChoice ="rock";
}
else if (computerChoice < 0.66); {
computerChoice = "paper";
}
else {
computerChoice = "scissors";
}
console.log(computerChoice);

Whats wrong?


#2

No semicolons after conditions. Wrote a longer explanation over here:


#3

Thank you very much!


#4

I am having a similar issue. I am unsure of my 'else' statement. My code is:

var userChoice = prompt("Do you choose rock, paper, or scissors?");
var computerChoice = Math.random();
console.log(computerChoice);
if (0 <= computerChoice && computerChoice <= 0.33) {
computerChoice = "rock";
else if (0.33 < computerChoice && computerChoice < 0.67) {
computerChoice = "paper";
}
else {
(0.67 <= computerChoice && computerChoice < 1) {
computerChoice = "scissors";
console.log(computerChoice);
}

What am I doing wrong?