Computer Choice: Part 2 Problem


#1

Does anyone know what is wrong with this code?

The error is : Oops, try again. There was a problem with your syntax.
SyntaxError: Unexpected token if

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

var computerChoice = Math.random();

if (computerChoice <= 0.33) {
    computerChoice = "rock";
};
esle if (computerChoice <= 66 && computerChoice > 0.33 ) {
    computerChoice = "paper";
};
else {
    computerChoice = "scissors";
    };

#2

At the else if line you write esle if maybe it's the problem


#3

Then what should I write?!


#4

Write else if instead of esle if , you misspelled else if


#5

As @chaoki said + get rid of the semicolons in your conditional structure:


#6

@chaoki is write, you misspelled the else if . You wrote esle if instead of else if
In addition, try to have a second look on this part:

The variable userChoice should be equal to the answer we get by asking the user "Do you choose rock, paper or scissors?"

You should write your codes like this:

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

And one more thing, remove the semicolon ( ; ) after your closing curly braces


#7

Thanks all!
The problem was misspelled (esle instead of else) and the semicolons after my closing curly braces.
but it was in lessons that we should put a semicolon after closing curly braces!


#8

In which lessons? Only the functions require semicolons on the curly braces because this statement does:

var NAME = VALUE;

and function(para){} is just a fancy form of VALUE