Review: Function Returning a Value

In JavaScript, a function returns a value by returning the value in the "return" statement to where the function was called. For example:

sum = add(a,b)

When we call the add(a,b) function and it executes its return statement, that returned value will be stored in the sum variable.

Syntax

return;
return expression;
expression Optional

The expression whose value is to be returned. If omitted, undefined is returned.