Created
June 18, 2018 04:02
-
-
Save marco-souza/6fc38fa0b6cffeae04b118fbde4018f9 to your computer and use it in GitHub Desktop.
Show filter, map and reduce use case
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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