Last active
February 23, 2017 15:16
-
-
Save halan/89d973205fae2fe4b72c6405d9c9f413 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
const lineItems = [ | |
{ name: 'Carmenere', price: 35, quantity: 2 }, | |
{ name: 'Cabernet', price: 50, quantity: 1 }, | |
{ name: 'Merlot', price: 98, quantity: 10 }, | |
]; | |
const totalLine = line => | |
line.quantity * line.price; | |
const sumTotal = lines => | |
lines.reduce((total, line) => total += totalLine(line), 0); | |
console.log(sumTotal(lineItems)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment