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:

Create the HTML code for each donor row by applying the forEach() method to the majorDonors variable, using writeDonorRow() as the callback function.

Add the text string

Major Donors
Donation Donor ID DateNameAddress Phone E-mail
to the value of the donorTable variable.

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 = "

"; Create the HTML

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 += ""; donorTable += ""; donorTable += ""; donorTable += ""; }

var majorDonors = writeDonorRow.forEach(); majorDonors = donors.filter(findMajorDonors); majorDonors = majorDonors.sort(donorSortDescending); donorTable +="

Major Donors
Donation Donor ID DateNameAddress Phone E-mail
$" + value[9].toLocaleString() + "" + value[0] + "" + value[10] + "" + value[2] + ", " + value[1] + "" + value[3] + "
" + value[4] + ", " + value[5] + " " + value[6] + "
" + value[7] + "" + value[8] + "
"; document.getElementById("donorTable").innerHTML = donorTable;

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!