Below the script element you just created, insert another script element that contains the function amountTotal()

3. Below the script element you just created, insert another script element that contains the function amountTotal(). The purpose of the amountTotal() function is to return the sum of all of the values in the amount array. There are no parameters for this function. Add the following commands to the function:

a. Declare a variable named total, setting its initial value to 0.

b. Create a For loop that loops through all of the values in the amount array. At each iteration of the loop, add the current value of the array item to the value of the total variable.

c. After the For loop is completed, return the value of the total variable.

Order now