STATEMENT:  function

function name([param] [, param] [..., param]) {statements}

The function statement declares a function with its specified parameters, which can include numbers, strings and objects. To return a value, a function must have a return statement specifying the value to return. The following code declares a function that calculates the average of three numbers and returns the result:

Code:
function calcaverage(a, b, c)
{
   return (a+b+c)/3;
}
document.write(calcaverage(2, 4, 6));

Copyright 1999 by Infinite Software Solutions, Inc.
Trademark Information