The return statement part 2

Function Return



Use the return statement to return a value.

For example, let's calculate the product of two numbers, and return the result.
function myFunction(a, b) {
return a * b;
}

var x = myFunction(5, 6);
// Return value will end up in x
// x equals 30
Try It Yourself

If you do not return anything from a function, it will return undefined.

Comments

Popular posts from this blog

Introducing object part 3

Comparison Operators part 2

Module 2