Skip to content

Instantly share code, notes, and snippets.

@afontcu
Last active September 29, 2017 11:50
Show Gist options
  • Save afontcu/428b1466f42d4fd550e5576e34283874 to your computer and use it in GitHub Desktop.
Save afontcu/428b1466f42d4fd550e5576e34283874 to your computer and use it in GitHub Desktop.
const limit = 10
const factor = 60
const moreThan = x => element => element.amount > x
const applyFactor = x => element => element.time / x
const sumValues = (accumulator, currentValue) => accumulator + currentValue
list
.filter(moreThan(limit))
.map(applyFactor(factor))
.reduce(sumValues)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment