Build Rock, Paper, Scissors Part 1


#1


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

SyntaxError: Unexpected identifier

Replace this line with your code. 

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


#2

Why is your console.log inside { }? Try taking them out. :slight_smile:


#3

Ok did that and still I get syntax error???


#4

Hi,

consider these logic

Doesn't look right.

Hint: In the first quoted code, doing


if(computerChoice <= 0.33)

makes more sense.

Also, you've got Illegal return statements.

Hint: You may want to do,

computerChoice = "rock";

for instance


#5

The first issue is both of your if conditions should be inside of parentheses:

if (condition) {
code executing if condition is met goes here;
}

The second issue is you are not following the instructions for the conditions. In the first if condition, the computerChoice should be compared to values between 0 and 0.33. Since Math.random() returns a random number between 0 and 1, you can look for values below 0.34 or

computerChoice < 0.34.

Your second if condition should check for values over 0.33 and less than 0.66.

There is no need to use modulo in your conditions. Running 0%0.33 in javascript returns 0.33. You are basically checking for only that value instead of the range between 0 and 0.33.


#6

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