JavaScript
JavaScript return statement is outside a function
JavaScript found a return statement where function return semantics do not apply, such as top-level script code.
JavaScript
JavaScript found a return statement where function return semantics do not apply, such as top-level script code.
Observed message
SyntaxError: return not in function
Why it happens
How to fix it
Official reference
MDN: SyntaxError: return not in functionRelated errors
Explore more