JS Return - ashish9342/FreeCodeCamp GitHub Wiki
When a return statement is called in a function, the execution of this function is stopped. If specified, a given value is returned to the function caller. If the expression is omitted, undefined
is returned instead.
return [[expression]];
The following function returns the square of its argument, x, where x is a number.
function square(x) {
return x * x;
}
🚀 Run Code
The following function returns the product of its arguments, arg1 and arg2.
function myfunction(arg1, arg2){
var r;
r = arg1 * arg2;
return(r);
}
🚀 Run Code