Created
May 30, 2018 14:37
-
-
Save shx-dev/eb01bf0fb8c7ef81ada15232b5096152 to your computer and use it in GitHub Desktop.
Artigos | Array.reduce - O canivete suíço da programação funcional | Soma
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const products = [ | |
{ label: 'Product #1', value: 4.25 }, | |
{ label: 'Product #2', value: 2.50 }, | |
{ label: 'Product #3', value: 1.40 }, | |
]; | |
const total = products.reduce((total, { value }) => total + value, 0); /* 8.15 */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment