Computer Choice: Part 2 Syntax error


I am getting an error indicator saying missing ";" before statement at line 7 and a syntax error in the console stating SyntaxError: Unexpected token {

I can't seem to figure out where the mistake is, any help would be greatly appreciated!

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


The error is due to your else statement. An else statement is not allowed a condition. Your else statement should look like this.

else {
    computerChoice = "scissors";

Because the else statement runs only if the if, and else if conditions return false

Let me know if you need more explanation.
If that helped you get your head around it, please mark my reply as the solution.


That is a great help thank you, makes perfect sense now that you've outlined it!


You are most welcome :slight_smile:


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