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)
add(a,b)
function and it executes its return statement, that returned value will be stored in the sum variable.The return
statement ends function execution and specifies a value to be returned to the function caller.
Source: Mozilla, https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/return
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.