The return
statement ends the execution of the function and specifies a value to be returned to the caller function.
return
The return
statement exits from the code block when executed.
function addNumbers(a, b) {
return a + b;
}
console.log(addNumbers(10, 20); // Prints: 30
The return
statement in the above case added, the values are given in the two variables a
and b
and returned it back to the function caller.