JavaScript Code

Function return value in JavaScript

return keyword

In JavaScript, return keyword is used to return a value to the function call.

Function execution stops after return statement.


In the following program, we write a function add() that returns a value sum.

function add(a, b) {
  let sum = a + b;
  return sum;

output = add(3, 4);