-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjavascript.js
More file actions
69 lines (64 loc) · 1.41 KB
/
javascript.js
File metadata and controls
69 lines (64 loc) · 1.41 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
var soma = 0;
var cont = 0;
var total = 0;
var num = [];
var t;
var n;
var r = window.document.querySelector('#result');
function proxima() {
if (cont == 4) {
let resposta = window.confirm("Voce deseja informar mais de 4 notas?");
if (resposta == false) {
resultado();
}
}
var nota = window.document.querySelector('#nota');
n = Number(nota.value)
if(n==0){
var awnser =window.confirm('deseja enviar um valor nulo?');
if(awnser== true)
{
contar();
}
else{
resultado();
}
}
else{
contar();
}
}
function contar(){
num.push(n);
soma += n;
nota.value = "";
cont++;
}
function resultado() {
if (cont == 0) {
window.alert('Digite os Numeros');
}
else {
total = 0;
total = soma / cont;
for (var index = 0; index < num.length; index++) {
var itens = window.document.createElement('p');
itens.innerHTML = `teste ${num[index]}`;
r.appendChild(itens);
}
var media = window.document.createElement('p');
media.innerHTML = `A media: ${total}`;
r.appendChild(media);
}
}
function limpar() {
nota = 0;
soma = 0;
window.document.getElementById('nota').value = "";
r.innerHTML = "";
while (cont > 0) {
num.pop();
cont--;
}
cont = 0;
}