SyntaxError Unexpected Token Else


#1


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


My code looks fine, to me, but whenever I press save and submit code it comes up with "SyntaxError: unexpected token Else.".


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


#2

You don't need three equal operators because this is assignment not conditional,

instead,

computerChoice = "rock";

computerChoice = "paper";

computerChoice = "scissors";

And also the first else if statement is written incorrectly this is how a javascript else if statement is written,

else if (condition) {
//body 
}

and your condition should not include 0.33 and can simply be written,

else if (computerChoice <= 0.67)


#3

You spelt computerChoie === "rock" wrong


#4

Hey guys it's still saying 'SyntaxError' even though I changed what both of
you said.


#5

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