You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 3ffcfaf
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: assignments/array-methods.js
+86-7Lines changed: 86 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,6 @@
1
-
// A local community center is holding a fund rasising 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.
1
+
// A local community center is holding a fund-raising 5k fun run and has invited 50 small businesses to make a small donation
2
+
// on their behalf for some much needed updates to their facilities. Each business has assigned a representative to attend the
3
+
// event along with a small donation.
2
4
3
5
// Scroll to the bottom of the list to use some advanced array methods to help the event director gather some information from the businesses.
// The event director needs both the first and last names of each runner for their running bibs. Combine both the first and last names into a new array called fullName.
59
+
// The event director needs both the first and last names of each runner for their running bibs.
60
+
// Combine both the first and last names into a new array called fullName.
// The event director needs to have all the runner's first names converted to uppercase because the director BECAME DRUNK WITH POWER. Convert each first name into all caps and log the result
69
+
// The event director needs to have all the runner's first names converted to uppercase because the director
70
+
// BECAME DRUNK WITH POWER. Convert each first name into all caps and log the result
63
71
letallCaps=[];
72
+
allCaps=runners.map(arrObj=>{
73
+
return(`${arrObj.first_name.toUpperCase()}`);
74
+
});
64
75
console.log(allCaps);
65
76
77
+
66
78
// ==== Challenge 3: Use .filter() ====
67
-
// The large shirts won't be available for the event due to an ordering issue. Get a list of runners with large sized shirts so they can choose a different size. Return an array named largeShirts that contains information about the runners that have a shirt size of L and log the result
79
+
// The large shirts won't be available for the event due to an ordering issue. Get a list of runners with
80
+
// large sized shirts so they can choose a different size. Return an array named largeShirts that contains
81
+
// information about the runners that have a shirt size of L and log the result
82
+
functionisLarge(size){
83
+
returnsize.shirt_size==='L';
84
+
}
68
85
letlargeShirts=[];
86
+
largeShirts=runners.filter(isLarge);
69
87
console.log(largeShirts);
70
88
89
+
71
90
// ==== Challenge 4: Use .reduce() ====
72
91
// The donations need to be tallied up and reported for tax purposes. Add up all the donations into a ticketPriceTotal array and log the result
// 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.
101
+
// Now that you have used .forEach(), .map(), .filter(), and .reduce(). I want you to think of potential
102
+
// problems you could solve given the data set and the 5k fun run theme. Try to create and then solve 3 unique
103
+
// problems using one or many of the array methods listed above.
78
104
79
105
// Problem 1
106
+
// shirtGate was not handled by the marketing team and now it's up to you to send out emails to each person on the large
107
+
// shirt list. Create an array of L shirt people with name and email address
0 commit comments