-
Notifications
You must be signed in to change notification settings - Fork 0
/
ex12_lista.html
51 lines (34 loc) · 1.08 KB
/
ex12_lista.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Filhos</title>
</head>
<body>
<span>Qual o nome dos seus filhos?</span>
<input type="text" id="input_filhos"><br>
<button onclick="cadastrar()">Cadastrar</button><br>
<button onclick="atualizar()">Atualizar Família</button>
<div id="exibir"></div>
</body>
</html>
<script>
var filhos = [];
function cadastrar() {
var nomeFilho = input_filhos.value;
if (filhos != nomeFilho) {
filhos.push(nomeFilho);
} else {
alert('Não pode + de 1 filho com nomes iguais!')
}
}
function atualizar() {
var totalFilhos = filhos.length;
var custoParticular = totalFilhos * 3000;
var custoPublica = totalFilhos * 1500;
exibir.innerHTML = `Você tem ${totalFilhos} filhos <br>
s
Seu custo mensal: R$${custoParticular} <br> caso estudem em escola particular. ou R$${custoPublica} se estudarem em escola pública.`
}
</script>