-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
70 lines (59 loc) · 1.88 KB
/
script.js
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
70
numero = ['_', '_']
//Listas com os números
voto1 = ['4', '5']
voto2 = ['2', '3']
voto3 = ['1', '5']
//Variáveis dos candidatos
candidato1 = 0
candidato2 = 0
candidato3 = 0
//função que exibe o nome de cada candidato quando seu número é selecionado
function exibir() {
if (numero.toString() == voto1.toString()) {
document.getElementById('candidato').innerText = 'candidato1'
} else if (numero.toString() == voto2.toString()) {
document.getElementById('candidato').innerText = 'candidato2'
} else if (numero.toString() == voto3.toString()) {
document.getElementById('candidato').innerText = 'candidato3'
}
else {
document.getElementById('candidato').innerText = ''
}
}
function registrar_num(num_voto) {
if (numero[0] == '_') {
numero.shift()
numero.unshift(num_voto)
document.getElementById('num').innerText = numero.join(' ')
} else {
numero.pop()
numero.push(num_voto)
document.getElementById('num').innerText = numero.join(' ')
}
exibir()
}
function limpar() {
numero = ['_', '_']
document.getElementById('num').innerText = numero.join(' ')
document.getElementById('candidato').innerText = ' '
}
function confirmar() {
if (numero.toString() == voto1.toString()) {
candidato1 += 1
} else if (numero.toString() == voto2.toString()) {
candidato2 += 1
} else if (numero.toString() == voto3.toString()) {
candidato3 += 1
}
numero = ['_', '_']
document.getElementById('candidato').innerText = ' '
document.getElementById('num').innerText = numero.join(' ')
}
function finalizar() {
alert('Candidato1: ' + candidato1 + '\n' + 'Candidato2: ' + candidato2 + '\n' + 'Candidato3: ' + candidato3)
numero = ['_', '_']
document.getElementById('num').innerText = numero.join(' ')
candidato1 = 0
candidato2 = 0
candidato3 = 0
}