WHAT A LAMP Rotating Header Image

Make a Function

A is a named group of JavaScript statements that you can declare once, near the top of your script, and call over and over again.

Declaring a

name ([parameter] [, parameter] [..., paramenter]){
statements
return value
}

Call a

alert(“Total purchases come to ” + calculateTotal (10, 19.85))

Returning a value from a

calculateTotal (numberOrdered, itemPrice){
var totalPrice = (numberOrdered * itemPrice) + salesTax
return totalPrice
}

The call above will not get the result without the returning value.

Related posts

Comments are closed.