Created
February 3, 2018 01:09
-
-
Save jarbaspsf/9c5e51bdb4233b2b6d9d83036eef8d55 to your computer and use it in GitHub Desktop.
Exemplo filter, map reduce
This file contains 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
let profissionais = [ | |
{nome: "João", salario: 5000, idade: 27}, | |
{nome: "Lucas", salario: 7000, idade: 37}, | |
{nome: "Pedro", salario: 5500, idade: 35}, | |
{nome: "Thiago", salario: 4500, idade: 24}, | |
{nome: "Felipe", salario: 4500, idade: 23}, | |
{nome: "Alexandre", salario: 4000, idade: 20}, | |
] | |
let somaSalariosAte30Anos = profissionais | |
.filter(n => n.idade <= 30) | |
.map(n => n.salario) | |
.reduce((a,b) => a + b) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment