Skip to content

Instantly share code, notes, and snippets.

@ilya-korotya
Last active June 27, 2018 09:07
Show Gist options
  • Save ilya-korotya/5a227aa4483b69c2e93a3cd38cebca2f to your computer and use it in GitHub Desktop.
Save ilya-korotya/5a227aa4483b69c2e93a3cd38cebca2f to your computer and use it in GitHub Desktop.
Functional programming in JS
const isEven = x => x%2 === 0
const isBigThan = size => int => int > size
const pluceValue = value => int => value + int
const isInInterval = (start, end) => int => start < int && end > int
let res = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
.filter(isEven)
.filter(isBigThan(5))
.map(pluceValue(2))
.filter(isInInterval(7, 10))
console.log(res)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment