A function is defined using the function statement. The function statement requires:
function functionName (argument1, argument2) {
command block
}
The naming of functions follows basically the same rules as variables:
The list of arguments (parameters) passed to the function appears in parentheses and is separated by commas. The arguments are used to allow functions to import one or more values from outside the function. Even if the functions does not require arguments or parameters, you must supply the parentheses.