Created
January 12, 2019 01:59
-
-
Save iagocavalcante/d27b4794ce7f046a59fdacb6031f697f to your computer and use it in GitHub Desktop.
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
const usuarios = [ | |
{ nome: 'Aluno 1', parcelasFaltantes: 3, valor: 89.9 }, | |
{ nome: 'Aluno 2', parcelasFaltantes: 5, valor: 19.9 }, | |
{ nome: 'Aluno 1', parcelasFaltantes: 7, valor: 49.9 }, | |
{ nome: 'Aluno 1', parcelasFaltantes: 6, valor: 69.9 }, | |
{ nome: 'Aluno 1', parcelasFaltantes: 2, valor: 99.9 } | |
] | |
const totalPorUsuario = usuario => | |
usuario.parcelasFaltantes * usuario.valor; | |
const soma = (a, b) => a + b; | |
const somatorioTotal = usuarios => | |
usuarios.map(totalPorUsuario).reduce(soma, 0); | |
console.log('valor total faltante =>', somatorioTotal(usuarios)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment