Created
February 18, 2017 22:32
-
-
Save halan/09cfe39e0e51eecd41d0e91522e8c373 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 totalLine = line => | |
line.quantity * line.price; | |
const sum = (a, b) => a + b; | |
const map = fn => xs => xs.map(fn); | |
const reduce = (fn, ini) => xs => xs.reduce(fn, ini) | |
const sumTotal = lines => | |
reduce(sum, 0)(map(totalLine)(lines)); | |
console.log(sumTotal(lineItems)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment