Created
August 30, 2018 01:45
-
-
Save JorgeMadson/0cf93da52b63a7f7c16ec9e020941d3d to your computer and use it in GitHub Desktop.
Revisão Javascript Programação Funcional Array 2 - forEach
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
// Usando o array anterior | |
var prova = [{ aluno: 'Fogaça', nota: 9.5 }, | |
// ... | |
]; | |
var somaNotas = 0; | |
var aprovados = prova.forEach(function (item) { | |
somaNotas += item.nota; | |
}); | |
var media = somaNotas / prova.length | |
console.log(media); | |
// Resultado: | |
// 8.75 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment