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.

function product(a, b)
return a*b

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


You may also like...