Created
September 18, 2020 19:12
-
-
Save arnonate/2ef9adfc1abfc86c0df53fb4e6abe210 to your computer and use it in GitHub Desktop.
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
// Reduce can be used to sum all products | |
const products = [{ price: 1 }, { price: 2 }, { price: 3 }, { price: 4 }]; | |
function sumAllPrices(products) { | |
return products.reduce((sum, product) => sum + product.price, 0); | |
} | |
sumAllPrices(products); // 425 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment