Defining Functions

A function definition consists of the function keyword, followed by:

For example, to define a simple function named square, you type

function square(number) {
  return number * number;
}

The function name is square; the argument is number. The statement is return number * number. The function returns the value of the argument multiplied by itself.