Invalid Return


#1

When I run this code( I replaced real comparisons with simple number comparisons to try to find problem) It says -Invalid return- I ran it through a code checker and it told me my return statements were illegal- how do i fix it

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

var computerChoice = Math.random();

console.log(computerChoice);

if (0===0) {
return"rock";
} else if (0===3) {
return"paper";
} else {
return"scissors";
}


#2

Get rid of the return. Return is a keyword used in function to return from the function to the calling scope or to return by also returning a value. It has nothing to do outside of the context of functions as their is no sub scope from which you could return (you are already on top level). Rather assign the value to your computerChoice variable.