Please help with part 4. rock, paper, scissors


#1

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


After typing my code I still get a syntax error message. Have no idea what I'm doing wrong.


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


#2

if/else syntax:

if (condition1) {
    block of code to be executed if condition1 is true
} else if (condition2) {
    block of code to be executed if the condition1 is false and condition2 is true
} else {
    block of code to be executed if the condition1 is false and condition2 is false
}

So, your conditions should be inside the ( ).


#3

Thanks denys.matsevych. That was an oversight on my part. I really appreciate the help


#4

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