I need help! 4 Computer Choice: Part 2 "SyntaxError: Unexpected token }"


#1

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


Replace this line with your code. 

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

var computerChoice = Math.random();
    console.log(computerChoice);

if (computerChoice <= 0.33) {
    console.log("rock");
} else if (computerChoice <=0.66) {
    console.log("paper");
} else (computerChoice >=1) 
    console.log("scissors");
};


#2

else can't have a condition, since it is everything else. If you give it a condition, it might not cover everything


#3

okay I took out the condition, though, the console did not log paper or rock or scissors it logged a number instead. wasnt the goal to get the computer to log paper, rock, or scissors?


#4

it should, can i see an updated version of your code?


#5

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

var computerChoice = Math.random();
console.log(computerChoice);

if (computerChoice <= 0.33) {
console.log("rock");
} else if (computerChoice <=0.66) {
console.log("paper");
} else {
console.log("scissors");
};

here it is


#6

Okay nevermind I see it now lol the issue is the computer and I kept picking the same choice. I chose paper on the first one and then chose paper on the second go and we picked the same one both times lol I just tried the code again and it worked


#7

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