Skip to content

Commit 86ede43

Browse files
committed
JS
Array 1-4 challenges done
1 parent ee12d62 commit 86ede43

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

‎assignments/array-methods.js‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,18 @@ console.log(allCaps);
6767
// ==== Challenge 3: Use .filter() ====
6868
// 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
6969
let largeShirts = [];
70+
71+
largeShirts = runners.filter(function(element){
72+
return element.shirt_size === 'L';
73+
});
7074
console.log(largeShirts);
7175

7276
// ==== Challenge 4: Use .reduce() ====
7377
// 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
7478
let ticketPriceTotal = [];
79+
80+
ticketPriceTotal = runners.reduce((acc, next) => acc + next.donation, 0);
81+
7582
console.log(ticketPriceTotal);
7683

7784
// ==== Challenge 5: Be Creative ====

0 commit comments

Comments
 (0)