Part 2: Why am I getting an illegal return statement?


#1


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


SyntaxError: Illegal return statement


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


#2

On this part, return is not needed, you actually need to set a value for computerChoice, like:

if (computerChoice < 0.34) {
	computerChoice = "rock";
}

#3

I'm still getting the same illegal return statement message.

I updated my code to the following: Is it the last statement that is causing the issue?var userChoice = prompt("Do you choose rock, paper, or scissors?")
computerChoice = Math.random()
console.log(computerChoice)
if (computerChoice < 0.34) {
computerChoice = "rock";
}
else if (computerChoice > 0.66) {
computerChoice = "scissors";
}
else {
return "paper";
}


#4

never mind i have it. Thank you for your help.