Skip to content

Instantly share code, notes, and snippets.

@halan
Created February 18, 2017 22:32
Show Gist options
  • Save halan/09cfe39e0e51eecd41d0e91522e8c373 to your computer and use it in GitHub Desktop.
Save halan/09cfe39e0e51eecd41d0e91522e8c373 to your computer and use it in GitHub Desktop.
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