Skip to content

Commit d95f4a8

Browse files
committed
arrays v2
1 parent 2c16465 commit d95f4a8

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

‎assignments/array-methods.js‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,18 @@ console.log(allCaps);
7676

7777
// ==== Challenge 3: Use .filter() ====
7878
// 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-
let largeShirts = [];
79+
let largeShirts = runners.filter(function(sizes){
80+
return sizes.shirt_size == "L";
81+
82+
});
8083
console.log(largeShirts);
8184

8285
// ==== Challenge 4: Use .reduce() ====
8386
// 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
84-
let ticketPriceTotal = [];
87+
let ticketPriceTotal = runners.reduce(function (accumulator, currentValue) {
88+
return accumulator + currentValue.donation;
89+
},0);
90+
8591
console.log(ticketPriceTotal);
8692

8793
// ==== Challenge 5: Be Creative ====

0 commit comments

Comments
 (0)