Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Instructions Link JS files Go to the ah_report.html file and directly above the closing tag, insert script elements to link the page to the ah_donors.js

Instructions

Link JS files

Go to the ah_report.html file and directly above the closing tag, insert script elements to link the page to the ah_donors.js and ah_report.js files in that order. Defer the loading and running of both script files until after the page has loaded.

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:

Open the ah_donors.js file. Study the content of the multidimensional array named donors. Note that the first column of the array (with an index of 0) contains the ID of each donor, the second column (index 1) contains the donors first name, the third column (index 2) contains the donors last name, and so forth. The amount of each donation is stored in the tenth column (index 9). Do not make any changes to the content of this file.

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 summaryTable storing 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 div element with the ID donationSummary to the value of thesummaryTable 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 majorDonorsvariable using the callback function donorSortDescending().

Donor Table

Create a variable named donorTablethat 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:

 

Add the text string

Major Donors
Donation Donor ID Date Name Address Phone E-mail

to the value of the donorTable variable.

Set the innerHTML property of the div element with the ID donorTableto the value of thedonorTablevariable.

Donor Rows

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

-------------

"use strict";

/* New Perspectives on HTML5 and CSS3, 7th Edition Tutorial 10 Case Problem 3

Author: Savannah Thieneman Date: 11/14/18 Filename: ah_report.js 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 += "$" + 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 += ""; }This is the ah_donors.js file var donors = [ ["donor87", "Mildred", "Moore", "9451 Pearse Grove Drive", "Maysville", "KY", "41056", "606-555-2928", "mmoore@example.com/mail", 200, "3/13/2018"], ["donor88", "Jodi", "Wells", "3463 Wolfe Lane", "Lexington", "KY", "40503", "859-555-4667", "jwells@example.com/mail", 1000, "3/13/2018"], ["donor89", "Irene", "Berry", "8058 King Villas Lane", "Louisville", "KY", "40211", "502-555-2851", "iberry@example.com/mail", 2000, "3/15/2018"], ["donor90", "Guillermo", "Shafer", "2862 Roppe Street", "Lexington", "KY", "40506", "859-555-9374", "gshafe@example.com/mail", 200, "3/16/2018"], ["donor91", "Monica", "Gray", "7383 Galwey Lane", "Bowling Green", "KY", "42104", "270-555-3249", "mgray@example.com/mail", 200, "3/17/2018"], ["donor92", "Jerold", "Cole", "9047 Temple Lane", "Frankfort", "KY", "40601", "502-555-9286", "jcole@example.com/mail", 100, "3/20/2018"], ["donor93", "David", "Butler", "6637 Clarence Street", "Lexington", "KY", "40512", "859-555-1769", "dbutle@example.com/mail", 200, "3/20/2018"], ["donor94", "Mae", "Tillman", "9307 Eden Avenue", "Frankfort", "KY", "40604", "502-555-7789", "mtillm@example.com/mail", 2000, "3/21/2018"], ["donor95", "Raymond", "Adams", "1039 Hill Court", "Bowling Green", "KY", "42101", "270-555-1686", "radams@example.com/mail", 200, "3/23/2018"], ["donor96", "James", "Smith", "8275 Strandside Way", "Lexington", "KY", "40518", "859-555-8359", "jsmith@example.com/mail", 200, "3/23/2018"], ["donor97", "Frederick", "Turner", "4106 Crampton Court", "Albany", "KY", "42602", "606-555-6493", "fturne@example.com/mail", 100, "3/23/2018"], ["donor98", "Alfred", "Woodson", "6211 Connell Way", "Louisville", "KY", "40211", "502-555-2485", "awoods@example.com/mail", 100, "3/29/2018"], ["donor99", "Matthew", "Hebert", "7697 Parkgate Street", "Louisville", "KY", "40220", "502-555-1445", "mheber@example.com/mail", 100, "3/29/2018"], ["donor100", "Michelle", "Hatfield", "2838 King Avenue SW", "Bowling Green", "KY", "42104", "270-555-5533", "mhatfi@example.com/mail", 100, "4/3/2018"], ["donor101", "Jeffrey", "Harris", "397 Crescent Drive", "Louisville", "KY", "40220", "502-555-7281", "jharri@example.com/mail", 100, "4/5/2018"], ["donor102", "Corene", "Reece", "1089 Sandstone Court", "Bowling Green", "KY", "42102", "270-555-5783", "creece@example.com/mail", 200, "4/7/2018"], ["donor103", "Francis", "Guzman", "9409 Applemarket Avenue", "Lexington", "KY", "40516", "859-555-7487", "fguzma@example.com/mail", 100, "4/11/2018"], ["donor104", "Patricia", "Curtis", "5837 Croft Street", "Lexington", "KY", "40518", "859-555-2443", "pcurti@example.com/mail", 100, "4/13/2018"], ["donor105", "William", "Joyce", "5317 Mead Court", "Louisville", "KY", "40206", "502-555-9262", "wjoyce@example.com/mail", 100, "4/14/2018"], ["donor106", "Margaret", "Parra", "4702 Barley Hill Street", "Louisville", "KY", "40213", "502-555-4388", "mparra@example.com/mail", 200, "4/17/2018"], ["donor107", "Toni", "Bourdon", "1567 House Street", "Ashland", "KY", "41102", "606-555-2757", "tbourd@example.com/mail", 5000, "4/19/2018"], ["donor108", "Joshua", "Voss", "6166 Sarsfield Lane", "Winchester", "KY", "40392", "859-555-9684", "jvoss@example.com/mail", 100, "4/19/2018"], ["donor109", "Marilyn", "Sams", "1321 Causeway Drive", "London", "KY", "40744", "606-555-2458", "msams@example.com/mail", 100, "4/20/2018"], ["donor110", "Donald", "Brown", "8500 Baggot Lane", "Frankfort", "KY", "40601", "502-555-2786", "dbrown@example.com/mail", 100, "4/26/2018"], ["donor111", "Richard", "Grahm", "1985 Henrietta Drive", "Maysville", "KY", "41056", "606-555-7384", "rgrahm@example.com/mail", 500, "4/26/2018"], ["donor112", "Marjorie", "Mendez", "3087 Abbey Terrace Lane", "Lexington", "KY", "40523", "859-555-2683", "mmende@example.com/mail", 500, "4/28/2018"], ["donor113", "Royce", "Natividad", "6245 Benburb Lane", "Louisville", "KY", "40203", "502-555-8112", "rnativ@example.com/mail", 100, "5/2/2018"], ["donor114", "Robert", "Pelletier", "3350 Arnott Circle", "Lexington", "KY", "40519", "859-555-6454", "rpelle@example.com/mail", 200, "5/2/2018"], ["donor115", "Mary", "Tso", "2246 College Street", "Louisville", "KY", "40215", "502-555-3586", "mtso@example.com/mail", 200, "5/2/2018"], ["donor116", "Michele", "Reed", "820 Brabazon Court", "Shelbyville", "KY", "40065", "502-555-5133", "mreed@example.com/mail", 200, "5/4/2018"], ["donor117", "Tiffany", "Grainger", "6653 Jacknell Street", "Lexington", "KY", "40518", "859-555-6554", "tgrain@example.com/mail", 200, "5/4/2018"], ["donor118", "Megan", "Sanders", "1898 Strandside Lane", "Lexington", "KY", "40510", "859-555-3857", "msande@example.com/mail", 100, "5/4/2018"], ["donor119", "Grace", "Montgomery", "749 Jewell Drive", "Ashland", "KY", "41101", "606-555-2839", "gmontg@example.com/mail", 200, "5/4/2018"], ["donor120", "Harold", "Cook", "1897 Vale Street", "Bowling Green", "KY", "42104", "270-555-1134", "hcook@example.com/mail", 1000, "5/5/2018"], ["donor121", "Nicolette", "Howe", "7179 Serlondes Street", "Frankfort", "KY", "40604", "502-555-3462", "nhowe@example.com/mail", 1000, "5/9/2018"], ["donor122", "Todd", "Rhodes", "3287 Beresford Avenue", "Lexington", "KY", "40505", "859-555-8411", "trhode@example.com/mail", 200, "5/11/2018"], ["donor123", "Louis", "Valdez", "9902 Chancery Drive", "Louisville", "KY", "40222", "502-555-9779", "lvalde@example.com/mail", 100, "5/16/2018"], ["donor124", "Cruz", "Thomas", "4636 New Terrace Street", "Lexington", "KY", "40504", "859-555-7678", "cthoma@example.com/mail", 100, "5/16/2018"], ["donor125", "Jennifer", "Garcia", "2175 Horsefield Avenue", "Lexington", "KY", "40510", "859-555-4523", "jgarci@example.com/mail", 200, "5/16/2018"], ["donor126", "Robert", "Payne", "5384 Weatherline Drive", "Winchester", "KY", "40391", "859-555-6626", "rpayne@example.com/mail", 200, "5/16/2018"], ["donor127", "Jack", "Jackson", "1346 Quay Street", "Bowling Green", "KY", "42102", "270-555-3749", "jjacks@example.com/mail", 500, "5/19/2018"], ["donor128", "Jerry", "Medina", "5966 Crampton Row", "Louisville", "KY", "40205", "502-555-2267", "jmedin@example.com/mail", 100, "5/19/2018"], ["donor129", "Jorge", "Valdes", "3676 Church Place Court", "Louisville", "KY", "40201", "502-555-5134", "jvalde@example.com/mail", 25000, "5/19/2018"], ["donor130", "Valerie", "Hoskins", "1752 Bolton Avenue", "Louisville", "KY", "40209", "502-555-2385", "vhoski@example.com/mail", 100, "5/23/2018"], ["donor131", "John", "Arnold", "3547 Wellington Lane", "Lexington", "KY", "40509", "859-555-2484", "jarnol@example.com/mail", 100, "5/25/2018"], ["donor132", "Jordan", "Jones", "3344 Bakehouse Lawn", "Bowling Green", "KY", "42104", "270-555-5633", "jjones@example.com/mail", 100, "5/25/2018"], ["donor133", "John", "Randall", "3234 Clare Close Avenue", "Bowling Green", "KY", "42101", "270-555-5265", "jranda@example.com/mail", 100, "5/29/2018"], ["donor134", "Bonnie", "Jones", "2308 Dean Street", "Louisville", "KY", "40205", "502-555-9219", "bjones@example.com/mail", 1000, "5/31/2018"], ["donor135", "Kathy", "Hayes", "203 Garden Court", "Bowling Green", "KY", "42103", "270-555-8545", "khayes@example.com/mail", 100, "6/2/2018"], ["donor136", "Gerald", "Boone", "595 Brighton Drive", "Bowling Green", "KY", "42102", "270-555-1456", "gboone@example.com/mail", 100, "6/5/2018"], ["donor137", "James", "Cash", "693 Ellis Quay Avenue", "Louisville", "KY", "40222", "502-555-9726", "jcash@example.com/mail", 100, "6/5/2018"], ["donor138", "Maria", "Swindler", "4488 Parnell Street", "Frankfort", "KY", "40601", "502-555-5856", "mswind@example.com/mail", 100, "6/5/2018"], ["donor139", "Mildred", "Smith", "7762 French Avenue", "Lexington", "KY", "40517", "859-555-9831", "msmith@example.com/mail", 1000, "6/8/2018"], ["donor140", "Patricia", "Hall", "9820 Fosters Road", "Maysville", "KY", "41056", "606-555-2489", "phall@example.com/mail", 200, "6/12/2018"], ["donor141", "Clifford", "Chandler", "4011 Hilton Lane", "Lexington", "KY", "40509", "859-555-2424", "cchand@example.com/mail", 100, "6/15/2018"], ["donor142", "Terrance", "Sterling", "6944 Gardiner Drive", "Louisville", "KY", "40213", "502-555-8642", "tsterl@example.com/mail", 100, "6/21/2018"], ["donor143", "James", "Huard", "645 Close Street", "Bowling Green", "KY", "42101", "270-555-7112", "jhuard@example.com/mail", 1000, "6/22/2018"], ["donor144", "Kathleen", "Todd", "929 Lookout Way", "Bowling Green", "KY", "42101", "270-555-6345", "ktodd@example.com/mail", 200, "6/22/2018"],

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

AutoCAD Database Connectivity

Authors: Scott McFarlane

1st Edition

0766816400, 978-0766816404

More Books

Students also viewed these Databases questions

Question

Test a check out request for an empty shopping cart.

Answered: 1 week ago

Question

5. Identify three characteristics of the dialectical approach.

Answered: 1 week ago

Question

7. Identify six intercultural communication dialectics.

Answered: 1 week ago