Skip to content

Commit

Permalink
added external reducer
Browse files Browse the repository at this point in the history
  • Loading branch information
Abott1222 committed Nov 27, 2018
1 parent 02a0b6e commit e371a56
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions assignments/array-methods.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,14 @@ console.log(largeShirts);

// ==== Challenge 4: Use .reduce() ====
// 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
let ticketPriceTotal = runners.reduce(function(acc, runnerObj) {


const reducer = function(acc, runnerObj) {
return acc + runnerObj.donation;
}, 0)
}


let ticketPriceTotal = runners.reduce(reducer, 0)
console.log(ticketPriceTotal);

// ==== Challenge 5: Be Creative ====
Expand Down

0 comments on commit e371a56

Please sign in to comment.