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?");
var computerChoice = Math.random();

console.log(computerChoice);

if (computerChoice <=.33) {
    return "rock";
} else if (computerChoice <=.66) {
    return "paper";
} else (computerChoice <= 1) {
    return "scissors";
}


#2

The return statement ends function execution and specifies a value to be returned to the function caller.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/return

You have no function or function caller. Either create a function to put your if statements in, or assign the strings "rock", "paper", and "scissors" to an existing or new variable.

In the respective code blocks, change the value of computerChoice based on the rules stated above.

Since the instructions ask to assign it to computerChoice, do so:

computerChoice = "rock";

#3

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