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
Copy file name to clipboardExpand all lines: README.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,9 +18,9 @@ This task focuses on getting practice with callback functions by giving you an a
18
18
19
19
### Task 3: Array Methods
20
20
Use `.forEach()`, `.map()`, `.filter()`, and `.reduce()` to loop over an array with 50 objects in it. The [array-methods.js](assignments/array-methods.js) file contains several challenges built around a fundraising 5K fun run event.
21
-
*[] Review the contents of the [array-methods.js](assignments/array-methods.js) file.
22
-
*[] Complete the problems provided to you
23
-
*[] Notice the last three problems are up to you to create and solve. This is an awesome opportunity for you to push your critical thinking about array methods, have fun with it.
21
+
*[x] Review the contents of the [array-methods.js](assignments/array-methods.js) file.
22
+
*[x] Complete the problems provided to you
23
+
*[x] Notice the last three problems are up to you to create and solve. This is an awesome opportunity for you to push your critical thinking about array methods, have fun with it.
24
24
25
25
### Task 4: Closures
26
26
We have learned that closures allow us to access values in scope that have already been invoked.
// 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.
// 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
63
-
letallCaps=[];
66
+
letallCaps=runners.map((runner)=>{
67
+
return`${runner.first_name.toUpperCase()}`;
68
+
});
64
69
console.log(allCaps);
65
70
66
71
// ==== Challenge 3: Use .filter() ====
67
72
// 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
68
-
letlargeShirts=[];
73
+
letlargeShirts=runners.filter((runner)=>{
74
+
returnrunner.shirt_size==='L';
75
+
});
69
76
console.log(largeShirts);
70
77
71
78
// ==== Challenge 4: Use .reduce() ====
72
79
// 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 solve 3 unique problems using one or many of the array methods listed above.
78
87
79
-
// Problem 1
88
+
// Problem 1 - An e-mail list for sending out news and updates to all the runners
89
+
letemails=[];
90
+
runners.forEach((runner)=>{
91
+
emails.push(runner.email);
92
+
});
93
+
console.log(emails);
80
94
81
-
// Problem 2
95
+
// Problem 2 - The total donations for a given company (using Skinix as example)
0 commit comments