Skip to content

Commit 4baa1ce

Browse files
committed
ft(get sum of all donations made)
1 parent c5fda12 commit 4baa1ce

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

‎assignments/array-methods.js‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,20 @@ console.log(allCaps);
7979
// ==== Challenge 3: Use .filter() ====
8080
// 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
8181
let largeShirts = [];
82+
runners.filter(runner => {
83+
if(runner.shirt_size === "L"){
84+
largeShirts.push(runner)
85+
}
86+
})
8287
console.log(largeShirts);
88+
console.table(largeShirts);
8389

8490
// ==== Challenge 4: Use .reduce() ====
8591
// 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
8692
let ticketPriceTotal = [];
93+
let donations = runners.map(runner => runner.donation);
94+
let totalDonations = donations.reduce((a, b) => a + b)
95+
ticketPriceTotal.push(totalDonations);
8796
console.log(ticketPriceTotal);
8897

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

0 commit comments

Comments
 (0)