Skip to content

Commit 108ca2e

Browse files
Lambda_School_Loaner_102Lambda_School_Loaner_102
authored andcommitted
Finished Challenge bloominstituteoftechnology#4 from array-methods.js
1 parent a002d20 commit 108ca2e

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

‎assignments/array-methods.js‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,15 +114,19 @@ const largeShirts = runners.filter (x4 => x4.shirt_size = 'L');
114114
console.log(largeShirts);
115115

116116

117+
// ==== Challenge 4: Use .reduce() ====
118+
// 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
119+
// let ticketPriceTotal = [];
120+
// console.log(ticketPriceTotal);
117121

122+
let ticketPriceTotal = runners.reduce(function (accumulator, runner) {
123+
return accumulator + runner.donation;
124+
}, 0);
118125

119126

127+
console.log(ticketPriceTotal);
120128

121129

122-
// ==== Challenge 4: Use .reduce() ====
123-
// 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
124-
// let ticketPriceTotal = [];
125-
// console.log(ticketPriceTotal);
126130

127131
// ==== Challenge 5: Be Creative ====
128132
// 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.

0 commit comments

Comments
 (0)