Create a For loop that loops through all of the values in the amount array.
PART I – Scenario
The Lighthouse II (not affiliated with our previous assignment) is a charitable organization located in central Kentucky that matches donors with needy groups. The fundraising coordinator for The Lighthouse is Aaron Kitchen. On a Web page available only to Lighthouse staff, Aaron wants to display a list of information on recent donations, including the name and address of the donor, the amount donated, and the date of the donation. A list of donations from the last month has been downloaded from an external database and stored in a collection of arrays named firstName, lastName, street, city, state, zip, amount, and date. Aaron needs your help in displaying the data from those arrays in a Web table. He also wants a summary table that displays the total number of contributors and the total contribution amount.
Complete the following:
1. Using your text editor, open lhouse2.htm from the zipped file hereView in a new window , enter your name and the date in the head section, and then save the file.
2. The firstName, lastName, street, city, state, zip, amount, and date arrays have been created and populated for you in the list.js file.
In the head section of the document, insert a script element that points to this file. Also, note: Existing line in the starter lhouse2.htm it references lhouse.css not lhouse2.css – this needs correction.
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.
4. Scroll down the document and locate the div element with the ID data_list. Within the div element, add a script element that contains the following commands:
a. Write the following code to the document to create the header row for the table of contributions:
b. Create a For loop in which the counter variable starts at 0 and, while the counter is less than the length of the amount array, increase the counter in increments of 1.
c. Display every other row in the data list with a yellow background. To do this, within the For loop, insert an If condition that tests whether the counter variable is divisible evenly by 2 (Hint: Use the%modulus operator). If the counter variable is divisible by 2, write the following HTML tag:
Otherwise, write the following tag:
d. Next, within the For loop, write the HTML code
to the document, where date, amount, firstName, and lastName are the values of the date, amount, firstName, and lastName arrays for the index indicated by the current value of the For loop’s counter variable.
e. Next, within the For loop, write the HTML code
to the document, where street, city, state, and zip are the values of the street, city, state, and zip arrays for the current index value.
f. Finally, outside the For loop, write code that closes the Table with:
Date Amount First Name Last Name Address
date
amount
firstName
lastName
street
city, state zip
5. Go to the div element with the ID totals. Insert a script element that writes the HTML code
Summary
Contributors
contributions
Amount $
total
to the document, where contributions is the length of the amount array and total is the value returned by the amountTotal() function you created earlier.
6. Close the file, saving your changes.
7. Open lhouse2.html in your Web browser. Verify that a list of 35 contributions totaling $5175 is displayed in the table and that alternate rows of the contributor list have a yellow background.
All supporting files are in the Zip file lhouse2.zip
Click here to Order this paper at http://mypaperwriter.net/. 100% Original Content
PLACE THIS ORDER OR A SIMILAR ORDER WITH BEST NURSING TUTORS TODAY AND GET AN AMAZING DISCOUNT
The post Create a For loop that loops through all of the values in the amount array. appeared first on BEST NURSING TUTORS .