Skip to content

Instantly share code, notes, and snippets.

@jarbaspsf
Created February 3, 2018 01:09
Show Gist options
  • Save jarbaspsf/9c5e51bdb4233b2b6d9d83036eef8d55 to your computer and use it in GitHub Desktop.
Save jarbaspsf/9c5e51bdb4233b2b6d9d83036eef8d55 to your computer and use it in GitHub Desktop.
Exemplo filter, map reduce
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