Question
I've been working on this question for the past 2 hours and I'm still stuck. I think I need a pair of fresh eyes to
I've been working on this question for the past 2 hours and I'm still stuck. I think I need a pair of fresh eyes to look at it. This is what the question ask me to do:
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 donationTotalvariable 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.
Using the filter() method with the callback function findMajorDonors(), create an array named majorDonors.
Apply the sort() method to the majorDonorsvariable using the callback function donorSortDescending().
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 div element with the ID donorTable to the value of the donorTable variable.
And this is what I have, I don't know what I am doing wrong (I really think that I'm using the forEach method wrong and I think that I'm not completely understanding what it's asking to do for the major donors variable.):
var donationTotal = toLocaleString(0); donors.forEach(calcSum);
var summaryTable = "
Donors | " +donors.length+" |
---|---|
Total Donations | "+ "$"+donationTotal+" |
document.getElementById("donationSummary").innerHTML = summaryTable;
var donorTable = "
Donation | Donor ID | Date | Name | Address | Phone | |
---|---|---|---|---|---|---|
$" + value[9].toLocaleString() + " | "; donorTable += "" + value[0] + " | "; donorTable += "" + value[10] + " | "; donorTable += "" + value[2] + ", " + value[1] + " | "; donorTable += "" + value[3] + " " + value[4] + ", " + value[5] + " " + value[6] + " | "; donorTable += "" + value[7] + " | "; donorTable += "" + value[8] + " | "; donorTable += "
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored 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