-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexerarrayloop.js
23 lines (22 loc) · 917 Bytes
/
exerarrayloop.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
let listaAlunos = [
{ nome: 'Joao', notas: [5, 7.5, 8, 8, 4.5, 9] },
{ nome: 'Breno', notas: [10, 8.5, 10, 7.5, 9, 6.5] },
{ nome: 'Pedro', notas: [5.5, 8.3, 9.5, 8, 9, 6.9] },
{ nome: 'Bia', notas: [5.9, 8.5, 4, 8, 9.5, 6] },
{ nome: 'Angelino', notas: [0, 4.8, 9.2, 8.5, 4.9, 6.1] },
{ nome: 'Jaja', notas: [10, 4.3, 6.8, 8.25, 9.4, 6] },
{ nome: 'Frederico', notas: [3.5, 8, 10, 8.5, 9, 3.8] },
{ nome: 'Jonatas', notas: [6, 8.5, 8, 6.5, 7, 10] },
{ nome: 'Henrique', notas: [4, 8.2, 5.5, 8.5, 5.4, 6] },
];
const medias = []
for (const aluno of listaAlunos) {
let soma = 0;
for (const nota of aluno.notas) {
soma += nota;
}
const mediaAluno = (soma / aluno.notas.length).toFixed(1)
const mediaNumberAlunos = parseFloat (mediaAluno)
medias.push({nome: aluno.nome, média: mediaNumberAlunos});
}
console.log (medias);