r/JavaScriptTips • • Jun 29 '23

interesting reduce

Post image
21 Upvotes

3 comments sorted by

View all comments

4

u/trevedhek Jun 30 '23

Nice. A bit of duplicate calculation though.

const grandTotal = totalSum.reduce((total, customer) => {
   return total + customer.total;
}, 0);