Functions

As with PHP, JavaScript functions are used to separate out sections of code that perform a particular task. To create a function, declare it in the manner shown in following Example.

<script>
function product(a, b)
{
return a*b
}
</script>

This function takes the two parameters passed, multiplies them together, and returns the product.