Skip to content

Instantly share code, notes, and snippets.

@iagocavalcante
Created November 15, 2018 19:39
Show Gist options
  • Save iagocavalcante/4aaa44ac8ab5bc20a9d5ffd22012e465 to your computer and use it in GitHub Desktop.
Save iagocavalcante/4aaa44ac8ab5bc20a9d5ffd22012e465 to your computer and use it in GitHub Desktop.
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 }
]
let total = 0
usuarios.forEach(usuario => {
total += usuario.parcelasFaltantes * usuario.valor
})
console.log('valor total faltante =>', total)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment