Skip to content

Instantly share code, notes, and snippets.

@marco-souza
Created June 18, 2018 04:02
Show Gist options
  • Save marco-souza/6fc38fa0b6cffeae04b118fbde4018f9 to your computer and use it in GitHub Desktop.
Save marco-souza/6fc38fa0b6cffeae04b118fbde4018f9 to your computer and use it in GitHub Desktop.
Show filter, map and reduce use case
const list = [1,2,3,4,5,6,7,8,9,10]
// Soma dos quadrados dos impares de 1 a 10
const result = list
.filter(i => i % 2 === 1)
.map(i => i*i)
.reduce( (acc, cur) => acc + cur )
console.log(result)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment