-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathaula07.01_exercicio.html
More file actions
47 lines (37 loc) · 1.33 KB
/
aula07.01_exercicio.html
File metadata and controls
47 lines (37 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<!doctype html>
<html>
<head>
<title>Logica de Programação Javascript</title>
<meta charset="utf-8">
</head>
<body>
<h1>Lógica de programação com Javascript</h1>
<div id="output"></div>
</body>
<script>
//matriz
var alunos = [
{nome: 'Maria', notas: [2,5,8,9]},
{nome: 'José', notas: [2,1,5,8]},
{nome: 'João', notas: [1,5,3,2]},
{nome: 'Ana', notas: [4,5,3,8]},
{nome: 'lucia', notas: [2,1,8,5]}
];
var mediaAlunos = 0;
var msg = "";
for(var i = 0; i < alunos.length; i++){
msg += '<p><b> '+ alunos[i].nome +' </b></p>';
var notas = alunos[i].notas;
msg += '<p>notas: '+ notas.join(' | ') +' </p>'
var totalNotas = 0;
for(var j = 0; j < notas.length; j++){
totalNotas += notas[j];
}
var media = totalNotas / notas.length;
mediaAlunos += media;
msg += '<p>a média é: '+ media +'</p><hr>'
}
msg += '<p>A média de todos os alunos é: '+ (mediaAlunos / alunos.length) +'</p>'
document.querySelector('#output').innerHTML = msg;
</script>
</html>