Question
??can someone help with this problem?? Donation Summary Scroll down the file to the h1 heading entitled Donor Report. Directly below this h1 heading, insert
??can someone help with this problem??
Donation Summary
Scroll down the file to the h1 heading entitled Donor Report. Directly below this h1 heading, insert the following div elements into which you will insert the donation summary:
Next go to the ah_report.js file. The file contains four callback functions at the end of the file that you will use in generating the donation report. Take some time to study the content of these functions.
Variables
Create a variable named donationTotal in which you will calculate the total amount of the donations to Appalachian House. Set its initial value to 0.
Apply the forEach() method to the donors array, using the callback function calcSum(). This statement will calculate the donation total.
Create a variable named summaryTablestoring the text of the following HTML code
Donors | donors |
---|---|
Total Donations | $total |
where donors is the length of the donors array, and total is the value of the donationTotal variable, preceded by a $. Apply the toLocaleString() method to the donationTotal variable so that the total amount of donations is displayed with a thousands separator in the report.
Set the innerHTMLproperty of the divelement with the ID donationSummary to the value of the summaryTable variable.
Major Donors
Kendrick wants the report to show a list of the donors who contributed $1000 or more to Appalachian House. Using the filter()method with the callback function findMajorDonors(), create an array named majorDonors.
Kendrick wants the major donors list sorted in descending order. Apply the sort()method to the majorDonors variable using the callback function donorSortDescending().
Donor Table
Create a variable named donorTable that will store the HTML code for the table of major donors. Set the initial value of the variable to the text of the following HTML code:
Donation | Donor ID | Date | Name | Address | Phone |
---|
Set the innerHTML property of the divelement with the ID donorTable to the value of the donorTable variable.
********** ah_report.js file ********
"use strict";
/*
New Perspectives on HTML5 and CSS3, 7th Edition
10-3
Functions:
calcSum(donorAmt)
A callback function that adds the current donation amount in the array to the donationTotal variable
findMajorDonors(donorAmt)
A callback function that returns the value true only if the current donation amount in the array
is greater than or equal to 1000
donorSortDescending(a, b)
A callback function used to sort the donation amounts from the array in descending order
writeDonorRow(value)
A callback function that writes the HTML code for each table row that provides the contact
information for the donor
*/
function calcSum(donorAmt) {
donationTotal += donorAmt[9];
}
function findMajorDonors(donorAmt) {
return donorAmt[9] >= 1000;
}
function donorSortDescending(a, b) {
return b[9] - a[9];
}
function writeDonorRow(value) {
donorTable += "
donorTable += "
donorTable += "
donorTable += "
donorTable += "
donorTable += "
" + value[4] + ", " + value[5] + " " + value[6] + "
donorTable += "
donorTable += "
donorTable += "
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started