Question

In: Computer Science

// A local community center is holding a fund raising 5k fun run and has invited...

// A local community center is holding a fund raising 5k fun run and has invited 50 small businesses to make a small donation on their behalf for some much needed updates to their facilities. Each business has assigned a representative to attend the event along with a small donation.

// Scroll to the bottom of the list to use some advanced array methods to help the event director gather some information from the businesses.

const runners = [

{ id: 1, first_name: "Charmain", last_name: "Seiler", email: "[email protected]", shirt_size: "2XL", company_name: "Divanoodle", donation: 75 },

{ id: 2, first_name: "Whitaker", last_name: "Ierland", email: "[email protected]", shirt_size: "2XL", company_name: "Wordtune", donation: 148 },

{ id: 3, first_name: "Julieta", last_name: "McCloid", email: "[email protected]", shirt_size: "S", company_name: "Riffpedia", donation: 171 },

{ id: 4, first_name: "Martynne", last_name: "Paye", email: "[email protected]", shirt_size: "XL", company_name: "Wordware", donation: 288 },

{ id: 5, first_name: "Gussy", last_name: "Raraty", email: "[email protected]", shirt_size: "L", company_name: "Oozz", donation: 291 },

{ id: 6, first_name: "Yule", last_name: "Tommasetti", email: "[email protected]", shirt_size: "S", company_name: "Yodo", donation: 27 },

{ id: 7, first_name: "Kathie", last_name: "Majury", email: "[email protected]", shirt_size: "3XL", company_name: "Zoomcast", donation: 261 },

{ id: 8, first_name: "Tanner", last_name: "Branton", email: "[email protected]", shirt_size: "2XL", company_name: "Realmix", donation: 28 },

{ id: 9, first_name: "Sarina", last_name: "Lasham", email: "[email protected]", shirt_size: "XL", company_name: "Gigashots", donation: 110 },

{ id: 10, first_name: "Bertie", last_name: "Lonergan", email: "[email protected]", shirt_size: "3XL", company_name: "Skinte", donation: 62 },

{ id: 11, first_name: "Trevor", last_name: "Studd", email: "[email protected]", shirt_size: "S", company_name: "Cogidoo", donation: 76 },

{ id: 12, first_name: "Malachi", last_name: "Okeshott", email: "[email protected]", shirt_size: "M", company_name: "DabZ", donation: 91 },

{ id: 13, first_name: "Berget", last_name: "Logsdail", email: "[email protected]", shirt_size: "M", company_name: "Mymm", donation: 9 },

{ id: 14, first_name: "Loise", last_name: "Rivlin", email: "[email protected]", shirt_size: "2XL", company_name: "Linktype", donation: 204 },

{ id: 15, first_name: "Christan", last_name: "Kendall", email: "[email protected]", shirt_size: "XS", company_name: "Skinix", donation: 252 },

{ id: 16, first_name: "Kayla", last_name: "Whitwam", email: "[email protected]", shirt_size: "2XL", company_name: "Oyope", donation: 147 },

{ id: 17, first_name: "Heddie", last_name: "Heningam", email: "[email protected]", shirt_size: "L", company_name: "Skinix", donation: 172 },

{ id: 18, first_name: "Mace", last_name: "Ballinger", email: "[email protected]", shirt_size: "S", company_name: "Nlounge", donation: 266 },

{ id: 19, first_name: "Nola", last_name: "Abberley", email: "[email protected]", shirt_size: "XL", company_name: "Photospace", donation: 148 },

{ id: 20, first_name: "Nadine", last_name: "Tresler", email: "[email protected]", shirt_size: "3XL", company_name: "Wikido", donation: 292 },

{ id: 21, first_name: "Ulrikaumeko", last_name: "Vuittet", email: "[email protected]", shirt_size: "S", company_name: "Skinte", donation: 102 },

{ id: 22, first_name: "Saunder", last_name: "Spennock", email: "[email protected]", shirt_size: "3XL", company_name: "Kwimbee", donation: 213 },

{ id: 23, first_name: "Carmel", last_name: "Woffinden", email: "[email protected]", shirt_size: "S", company_name: "Rooxo", donation: 137 },

{ id: 24, first_name: "Marielle", last_name: "Kimmel", email: "[email protected]", shirt_size: "M", company_name: "Livetube", donation: 96 },

{ id: 25, first_name: "Brucie", last_name: "Burris", email: "[email protected]", shirt_size: "2XL", company_name: "Wordtune", donation: 128 },

{ id: 26, first_name: "Juan", last_name: "Berzon", email: "[email protected]", shirt_size: "3XL", company_name: "Einti", donation: 234 },

{ id: 27, first_name: "Sacha", last_name: "Olsen", email: "[email protected]", shirt_size: "2XL", company_name: "Viva", donation: 190 },

{ id: 28, first_name: "Jamey", last_name: "O'Nolan", email: "[email protected]", shirt_size: "XL", company_name: "Skinix", donation: 31 },

{ id: 29, first_name: "Morrie", last_name: "Rainard", email: "[email protected]", shirt_size: "XS", company_name: "Podcat", donation: 52 },

{ id: 30, first_name: "Fidel", last_name: "Roskelly", email: "[email protected]", shirt_size: "XS", company_name: "Avavee", donation: 5 },

{ id: 31, first_name: "Toni", last_name: "MacSweeney", email: "[email protected]", shirt_size: "M", company_name: "Jaloo", donation: 82 },

{ id: 32, first_name: "Jessey", last_name: "Walhedd", email: "[email protected]", shirt_size: "L", company_name: "Trilia", donation: 5 },

{ id: 33, first_name: "Karola", last_name: "Piper", email: "[email protected]", shirt_size: "3XL", company_name: "Yombu", donation: 110 },

{ id: 34, first_name: "Marley", last_name: "Mitchenson", email: "[email protected]", shirt_size: "M", company_name: "Zoonoodle", donation: 97 },

{ id: 35, first_name: "Marrilee", last_name: "Thrasher", email: "[email protected]", shirt_size: "XL", company_name: "Bluejam", donation: 17 },

{ id: 36, first_name: "Tye", last_name: "Manie", email: "[email protected]", shirt_size: "L", company_name: "Kanoodle", donation: 30 },

{ id: 37, first_name: "Charleen", last_name: "Sheering", email: "[email protected]", shirt_size: "3XL", company_name: "Jatri", donation: 262 },

{ id: 38, first_name: "Valma", last_name: "Eynaud", email: "[email protected]", shirt_size: "XS", company_name: "Jaxbean", donation: 212 },

{ id: 39, first_name: "Dollie", last_name: "McDarmid", email: "[email protected]", shirt_size: "S", company_name: "Kayveo", donation: 74 },

{ id: 40, first_name: "Minna", last_name: "Hymas", email: "[email protected]", shirt_size: "XS", company_name: "Vimbo", donation: 101 },

{ id: 41, first_name: "Jsandye", last_name: "Frend", email: "[email protected]", shirt_size: "XS", company_name: "Latz", donation: 156 },

{ id: 42, first_name: "Yevette", last_name: "Hacket", email: "[email protected]", shirt_size: "XL", company_name: "Lazzy", donation: 291 },

{ id: 43, first_name: "Hank", last_name: "Zebedee", email: "[email protected]", shirt_size: "L", company_name: "Gigashots", donation: 241 },

{ id: 44, first_name: "Jodie", last_name: "Stawell", email: "[email protected]", shirt_size: "S", company_name: "Jaxspan", donation: 262 },

{ id: 45, first_name: "Falito", last_name: "Karsh", email: "[email protected]", shirt_size: "S", company_name: "Mycat", donation: 239 },

{ id: 46, first_name: "Reginauld", last_name: "Purselowe", email: "[email protected]", shirt_size: "L", company_name: "Jabbersphere", donation: 11 },

{ id: 47, first_name: "Vida", last_name: "Tydd", email: "[email protected]", shirt_size: "S", company_name: "Quaxo", donation: 55 },

{ id: 48, first_name: "Anderea", last_name: "MacGiolla Pheadair", email: "[email protected]", shirt_size: "2XL", company_name: "Kwimbee", donation: 214 },

{ id: 49, first_name: "Bel", last_name: "Alway", email: "[email protected]", shirt_size: "S", company_name: "Voolia", donation: 107 },

{ id: 50, first_name: "Shell", last_name: "Baine", email: "[email protected]", shirt_size: "M", company_name: "Gabtype", donation: 171 },

];

// ==== Challenge 1: Use .forEach() ====

// The event director needs both the first and last names of each runner for their running bibs. Combine both the first and last names and populate a new array called `fullNames`. This array will contain just strings.

let fullNames = [];

console.log(fullNames);

// ==== Challenge 2: Use .map() ====

// The event director needs to have all the runners' first names in uppercase because the director BECAME DRUNK WITH POWER. Populate an array called `firstNamesAllCaps`. This array will contain just strings.

let firstNamesAllCaps = [];

console.log(firstNamesAllCaps);

// ==== Challenge 3: Use .filter() ====

// The large shirts won't be available for the event due to an ordering issue. We need a filtered version of the runners array, containing only those runners with large sized shirts so they can choose a different size. This will be an array of objects.

let runnersLargeSizeShirt = [];

console.log(runnersLargeSizeShirt);

// ==== Challenge 4: Use .reduce() ====

// The donations need to be tallied up and reported for tax purposes. Add up all the donations and save the total into a ticketPriceTotal variable.

let ticketPriceTotal = 0;

console.log(ticketPriceTotal);

// ==== Challenge 5: Be Creative ====

// Now that you have used .forEach(), .map(), .filter(), and .reduce(). I want you to think of potential problems you could solve given the data set and the 5k fun run theme. Try to create and then solve 3 unique problems using one or many of the array methods listed above.

// Problem 1

// Problem 2

// Problem 3

Solutions

Expert Solution

<!DOCTYPE html>
<html>
<body>

<h2>Golf Score Calculator.</h2>

<script>
const runners = [

{ id: 1, first_name: "Charmain", last_name: "Seiler", email: "[email protected]", shirt_size: "2XL", company_name: "Divanoodle", donation: 75 },

{ id: 2, first_name: "Whitaker", last_name: "Ierland", email: "[email protected]", shirt_size: "2XL", company_name: "Wordtune", donation: 148 },

{ id: 3, first_name: "Julieta", last_name: "McCloid", email: "[email protected]", shirt_size: "S", company_name: "Riffpedia", donation: 171 },

{ id: 4, first_name: "Martynne", last_name: "Paye", email: "[email protected]", shirt_size: "XL", company_name: "Wordware", donation: 288 },

{ id: 5, first_name: "Gussy", last_name: "Raraty", email: "[email protected]", shirt_size: "L", company_name: "Oozz", donation: 291 },

{ id: 6, first_name: "Yule", last_name: "Tommasetti", email: "[email protected]", shirt_size: "S", company_name: "Yodo", donation: 27 },

{ id: 7, first_name: "Kathie", last_name: "Majury", email: "[email protected]", shirt_size: "3XL", company_name: "Zoomcast", donation: 261 },

{ id: 8, first_name: "Tanner", last_name: "Branton", email: "[email protected]", shirt_size: "2XL", company_name: "Realmix", donation: 28 },

{ id: 9, first_name: "Sarina", last_name: "Lasham", email: "[email protected]", shirt_size: "XL", company_name: "Gigashots", donation: 110 },

{ id: 10, first_name: "Bertie", last_name: "Lonergan", email: "[email protected]", shirt_size: "3XL", company_name: "Skinte", donation: 62 },

{ id: 11, first_name: "Trevor", last_name: "Studd", email: "[email protected]", shirt_size: "S", company_name: "Cogidoo", donation: 76 },

{ id: 12, first_name: "Malachi", last_name: "Okeshott", email: "[email protected]", shirt_size: "M", company_name: "DabZ", donation: 91 },

{ id: 13, first_name: "Berget", last_name: "Logsdail", email: "[email protected]", shirt_size: "M", company_name: "Mymm", donation: 9 },

{ id: 14, first_name: "Loise", last_name: "Rivlin", email: "[email protected]", shirt_size: "2XL", company_name: "Linktype", donation: 204 },

{ id: 15, first_name: "Christan", last_name: "Kendall", email: "[email protected]", shirt_size: "XS", company_name: "Skinix", donation: 252 },

{ id: 16, first_name: "Kayla", last_name: "Whitwam", email: "[email protected]", shirt_size: "2XL", company_name: "Oyope", donation: 147 },

{ id: 17, first_name: "Heddie", last_name: "Heningam", email: "[email protected]", shirt_size: "L", company_name: "Skinix", donation: 172 },

{ id: 18, first_name: "Mace", last_name: "Ballinger", email: "[email protected]", shirt_size: "S", company_name: "Nlounge", donation: 266 },

{ id: 19, first_name: "Nola", last_name: "Abberley", email: "[email protected]", shirt_size: "XL", company_name: "Photospace", donation: 148 },

{ id: 20, first_name: "Nadine", last_name: "Tresler", email: "[email protected]", shirt_size: "3XL", company_name: "Wikido", donation: 292 },

{ id: 21, first_name: "Ulrikaumeko", last_name: "Vuittet", email: "[email protected]", shirt_size: "S", company_name: "Skinte", donation: 102 },

{ id: 22, first_name: "Saunder", last_name: "Spennock", email: "[email protected]", shirt_size: "3XL", company_name: "Kwimbee", donation: 213 },

{ id: 23, first_name: "Carmel", last_name: "Woffinden", email: "[email protected]", shirt_size: "S", company_name: "Rooxo", donation: 137 },

{ id: 24, first_name: "Marielle", last_name: "Kimmel", email: "[email protected]", shirt_size: "M", company_name: "Livetube", donation: 96 },

{ id: 25, first_name: "Brucie", last_name: "Burris", email: "[email protected]", shirt_size: "2XL", company_name: "Wordtune", donation: 128 },

{ id: 26, first_name: "Juan", last_name: "Berzon", email: "[email protected]", shirt_size: "3XL", company_name: "Einti", donation: 234 },

{ id: 27, first_name: "Sacha", last_name: "Olsen", email: "[email protected]", shirt_size: "2XL", company_name: "Viva", donation: 190 },

{ id: 28, first_name: "Jamey", last_name: "O'Nolan", email: "[email protected]", shirt_size: "XL", company_name: "Skinix", donation: 31 },

{ id: 29, first_name: "Morrie", last_name: "Rainard", email: "[email protected]", shirt_size: "XS", company_name: "Podcat", donation: 52 },

{ id: 30, first_name: "Fidel", last_name: "Roskelly", email: "[email protected]", shirt_size: "XS", company_name: "Avavee", donation: 5 },

{ id: 31, first_name: "Toni", last_name: "MacSweeney", email: "[email protected]", shirt_size: "M", company_name: "Jaloo", donation: 82 },

{ id: 32, first_name: "Jessey", last_name: "Walhedd", email: "[email protected]", shirt_size: "L", company_name: "Trilia", donation: 5 },

{ id: 33, first_name: "Karola", last_name: "Piper", email: "[email protected]", shirt_size: "3XL", company_name: "Yombu", donation: 110 },

{ id: 34, first_name: "Marley", last_name: "Mitchenson", email: "[email protected]", shirt_size: "M", company_name: "Zoonoodle", donation: 97 },

{ id: 35, first_name: "Marrilee", last_name: "Thrasher", email: "[email protected]", shirt_size: "XL", company_name: "Bluejam", donation: 17 },

{ id: 36, first_name: "Tye", last_name: "Manie", email: "[email protected]", shirt_size: "L", company_name: "Kanoodle", donation: 30 },

{ id: 37, first_name: "Charleen", last_name: "Sheering", email: "[email protected]", shirt_size: "3XL", company_name: "Jatri", donation: 262 },

{ id: 38, first_name: "Valma", last_name: "Eynaud", email: "[email protected]", shirt_size: "XS", company_name: "Jaxbean", donation: 212 },

{ id: 39, first_name: "Dollie", last_name: "McDarmid", email: "[email protected]", shirt_size: "S", company_name: "Kayveo", donation: 74 },

{ id: 40, first_name: "Minna", last_name: "Hymas", email: "[email protected]", shirt_size: "XS", company_name: "Vimbo", donation: 101 },

{ id: 41, first_name: "Jsandye", last_name: "Frend", email: "[email protected]", shirt_size: "XS", company_name: "Latz", donation: 156 },

{ id: 42, first_name: "Yevette", last_name: "Hacket", email: "[email protected]", shirt_size: "XL", company_name: "Lazzy", donation: 291 },

{ id: 43, first_name: "Hank", last_name: "Zebedee", email: "[email protected]", shirt_size: "L", company_name: "Gigashots", donation: 241 },

{ id: 44, first_name: "Jodie", last_name: "Stawell", email: "[email protected]", shirt_size: "S", company_name: "Jaxspan", donation: 262 },

{ id: 45, first_name: "Falito", last_name: "Karsh", email: "[email protected]", shirt_size: "S", company_name: "Mycat", donation: 239 },

{ id: 46, first_name: "Reginauld", last_name: "Purselowe", email: "[email protected]", shirt_size: "L", company_name: "Jabbersphere", donation: 11 },

{ id: 47, first_name: "Vida", last_name: "Tydd", email: "[email protected]", shirt_size: "S", company_name: "Quaxo", donation: 55 },

{ id: 48, first_name: "Anderea", last_name: "MacGiolla Pheadair", email: "[email protected]", shirt_size: "2XL", company_name: "Kwimbee", donation: 214 },

{ id: 49, first_name: "Bel", last_name: "Alway", email: "[email protected]", shirt_size: "S", company_name: "Voolia", donation: 107 },

{ id: 50, first_name: "Shell", last_name: "Baine", email: "[email protected]", shirt_size: "M", company_name: "Gabtype", donation: 171 },

];

// ==== Challenge 1: Use .forEach() ====

// The event director needs both the first and last names of each runner for their running bibs. Combine both the first and last names and populate a new array called `fullNames`. This array will contain just strings.

let fullNames = [];
runners.forEach(x => fullNames.push(x.first_name + ' ' + x.last_name));
console.log(fullNames);

// ==== Challenge 2: Use .map() ====

// The event director needs to have all the runners' first names in uppercase because the director BECAME DRUNK WITH POWER. Populate an array called `firstNamesAllCaps`. This array will contain just strings.

let firstNamesAllCaps = [];
firstNamesAllCaps = runners.map(x => x.first_name.toUpperCase())
console.log(firstNamesAllCaps);

// ==== Challenge 3: Use .filter() ====

// The large shirts won't be available for the event due to an ordering issue. We need a filtered version of the runners array, containing only those runners with large sized shirts so they can choose a different size. This will be an array of objects.

let runnersLargeSizeShirt = [];
runnersLargeSizeShirt = runners.filter(x => x.shirt_size == 'L')
console.log(runnersLargeSizeShirt);

// ==== Challenge 4: Use .reduce() ====

// The donations need to be tallied up and reported for tax purposes. Add up all the donations and save the total into a ticketPriceTotal variable.
let ticketPriceTotal = 0;
ticketPriceTotal = runners.reduce(function(x, y) {
        return (x + y.donation)
}, 0)
console.log(ticketPriceTotal);

// ==== Challenge 5: Be Creative ====

// Now that you have used .forEach(), .map(), .filter(), and .reduce(). I want you to think of potential problems you could solve given the data set and the 5k fun run theme. Try to create and then solve 3 unique problems using one or many of the array methods listed above.

// Persons belonging to education domain.
var eduPersons = runners.map(function(x) {
        if(x.email.endsWith('.edu')) {
        return 1; 
    } else {
        return 0;
    }
}).reduce((a, b) => (a + b))
console.log('People with eductional email: ' + eduPersons);

// Problem 2


// Problem 3


</script>
</body>
</html>
**************************************************

Thanks for your question. We try our best to help you with detailed answers, But in any case, if you need any modification or have a query/issue with respect to above answer, Please ask that in the comment section. We will surely try to address your query ASAP and resolve the issue.

Please consider providing a thumbs up to this question if it helps you. by Doing that, You will help other students, who are facing similar issue.


Related Solutions

5.) The average time to run the 5K fun run is 21 minutes and the standard...
5.) The average time to run the 5K fun run is 21 minutes and the standard deviation is 2.7 minutes. 45 runners are randomly selected to run the 5K fun run. Round all answers to 4 decimal places where possible and assume a normal distribution. What is the distribution of XX? XX ~ N(,) What is the distribution of ¯xx¯? ¯xx¯ ~ N(,) What is the distribution of ∑x∑x? ∑x∑x ~ N(,) If one randomly selected runner is timed, find...
The average time to run the 5K fun run is 20 minutes and the standard deviation...
The average time to run the 5K fun run is 20 minutes and the standard deviation is 2.3 minutes. 7 runners are randomly selected to run the 5K fun run. Round all answers to 4 decimal places where possible and assume a normal distribution. What is the distribution of X X ? X X ~ N(,) What is the distribution of ¯ x x¯ ? ¯ x x¯ ~ N(,) What is the distribution of ∑ x ∑x ? ∑...
The average time to run the 5K fun run is 21 minutes and the standard deviation...
The average time to run the 5K fun run is 21 minutes and the standard deviation is 2.5 minutes. 13 runners are randomly selected to run the 5K fun run. Round all answers to 4 decimal places where possible and assume a normal distribution. What is the distribution of XX? XX ~ N(,) What is the distribution of ¯xx¯? ¯xx¯ ~ N(,) What is the distribution of ∑x∑x? ∑x∑x ~ N(,) If one randomly selected runner is timed, find the...
The average time to run the 5K fun run is 22 minutes and the standard deviation...
The average time to run the 5K fun run is 22 minutes and the standard deviation is 2.5 minutes. 49 runners are randomly selected to run the 5K fun run. Round all answers to 4 decimal places where possible and assume a normal distribution. What is the distribution of XX? XX ~ N(,) What is the distribution of ¯xx¯? ¯xx¯ ~ N(,) What is the distribution of ∑x∑x? ∑x∑x ~ N(,) If one randomly selected runner is timed, find the...
1. Westpac City-Bay Fun Run is an annual fund-raising event that started in Adelaide in November...
1. Westpac City-Bay Fun Run is an annual fund-raising event that started in Adelaide in November of 1973. The main purpose of the event is to raise funds to support the athletic community of South Australia and to support local athletes and clubs while also engaging in a fun and friendly competitive activity. From its humble origins, the event grew each year and last year the run raised over 350,000 AUD for local athletes. It is a popular event with...
The community health nurse is preparing a program about hypertension for a local community center. The...
The community health nurse is preparing a program about hypertension for a local community center. The focus of the program is on the reduction of risk factors and compliance for those who have been diagnosed with high blood pressure. The target population includes older adults. a.The nurse focuses on primary hypertension because it accounts for 90% - 95% of hypertension in the United States. What risk factors does the nurse include for this population? Smoking, elevated LDL’s and total cholesterol,...
A local community health center identifies childhood obesity as a problem in the community. They collect...
A local community health center identifies childhood obesity as a problem in the community. They collect data demonstrating that the problem begins as early as elementary school. They develop a plan that includes clinical interventions at the health center and also at the elementary school. They ask the health department to help them organize an educational campaign and assist in evaluating the results. Working together, they are able to reduce the obesity rate among elementary school children by 50%. This...
in 200 words !!! You are a member at a local community center that is having...
in 200 words !!! You are a member at a local community center that is having their annual picnic serving 100 people. As a health educator, what measures should you ensure are in place to prevent food borne illness from spoiling the event?
Euromarket investment and fund raising   A​ U.S.-based multinational company has two​ subsidiaries, one in Mexico​ (local...
Euromarket investment and fund raising   A​ U.S.-based multinational company has two​ subsidiaries, one in Mexico​ (local currency, Mexican​ peso, MP) and one in Japan​ (local currency,​ yen, ¥). Forecasts of business operations indicate the following​ short-term financing position for each subsidiary​ (in equivalent U.S.​ dollars): ​Mexico: $85 million excess cash to be invested​ (lent) ​Japan: $70 million funds to be raised​ (borrowed) The management gathered the following​ data: Spot exchange rates MP11.56/US$ ¥108.57/US$ Forecast percent change -2.98% +1.54% Interest rates...
5. At your local family fun center, miniature golf is $12 per person for unlimited rounds...
5. At your local family fun center, miniature golf is $12 per person for unlimited rounds in a day, while each go-kart session is $8. If you played 3 rounds of miniature golf and rode the go-karts 3 times, what was the marginal cost of the3rd round of miniature golf? What was the marginal cost of the3rd go-kart session? $0 for miniature golf and $24 for go-karts $35 for miniature golf and $24 for go-karts $12 for miniature golf and...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT