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.