Last active
February 18, 2017 21:26
-
-
Save halan/6d5031251df7045aa339f9686cdc1df3 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 sumTotal = lines => { | |
let total = 0; | |
for(let i = 0; i < lines.length; i++) { | |
total += lines[i].quantity * lines[i].price; | |
} | |
return total; | |
} | |
console.log(sumTotal(lineItems)); // 1100 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment