The return statement part 3

Function Return



Another example:
function addNumbers(a, b) {
var c = a+b;
return c;
}
document.write( addNumbers(40, 2) );
//Outputs 42
Try It Yourself

The document.write command outputs the value returned by the function, which is the sum of the two parameters.

Comments

Popular posts from this blog

Introducing object part 3

Comparison Operators part 2

Module 2