ScanSkill

return

The return statement ends the execution of the function and specifies a value to be returned to the caller function.

Syntax

return

The return statement exits from the code block when executed.

Example

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.