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
// 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
67
letallCaps=[];
68
+
construnnerFirstName=runners.map(firstName=>{
69
+
firstName=firstName.first_name;
70
+
allCaps.push(firstName.toUpperCase());
71
+
})
64
72
console.log(allCaps);
65
73
66
74
// ==== Challenge 3: Use .filter() ====
67
75
// 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
76
letlargeShirts=[];
77
+
constlargeShirtSize=runners.filter(runner=>{
78
+
if(runner.shirt_size==='L'){
79
+
largeShirts.push(runner);
80
+
}
81
+
})
69
82
console.log(largeShirts);
70
83
71
84
// ==== Challenge 4: Use .reduce() ====
72
85
// 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.
78
98
79
99
// Problem 1
100
+
//Looking to locate runners participating from the skinix company.
101
+
letskinixCompanyRunners=[];
102
+
constfindCompany=runners.filter(runner=>{
103
+
if(runner.company_name==='Skinix'){
104
+
skinixCompanyRunners.push(runner);
105
+
}
106
+
})
107
+
console.log(skinixCompanyRunners);
80
108
81
109
// Problem 2
110
+
//sold out of small so everyone with a small gets a medium size.
Copy file name to clipboardExpand all lines: assignments/callbacks.js
+41-3Lines changed: 41 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,7 @@
1
1
// Create a callback function and invoke the function to test your work. You have been provided an example of a problem and a solution to see how this works with our items array. Study both the problem and the solution to figure out the rest of the problems.
0 commit comments