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


#1

<PLEASE USE THE FOLLOWING TEMPLATE TO HELP YOU CREATE A GREAT POST!>

<Below this line, add a link to the EXACT exercise that you are stuck at.>

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

<In what way does your code behave incorrectly? Include ALL error messages.>
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”;
}

<do not remove the three backticks above>

#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.