How to Create a Function in JavaScript
A function can be created in JavaScript by using the function statement, as follows:
function CalculateTotal(intInput)
{
var intTotal = 0;
intTotal = intInput*2;
return intTotal;
}
To call this function in JavaScript code, simply do this:
CalculateTotal(4);
The curly braces are required as part of the function statement.
August 14, 2007 at 7:49 pm
only just starting to learn javascript so this will be cool to keep checking back here. thanks