Skip to content

Instantly share code, notes, and snippets.

@Beraliv
Last active February 3, 2019 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Beraliv/4538dd7e707718518be7d2f44a1e7a00 to your computer and use it in GitHub Desktop.
Save Beraliv/4538dd7e707718518be7d2f44a1e7a00 to your computer and use it in GitHub Desktop.
const isEven = value => value % 2 === 0;
const mapFilterReduce = array =>
// gets values from array
array
// transforms value to value + 1
.map(value => value + 1)
// ignores odd values
.filter(isEven)
// applies addition
// starts from 0
.reduce((sum, value) => sum + value, 0);
const ages = [16, 23, 24]
mapFilterReduce(ages) // 24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment