-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
47 lines (40 loc) · 1.27 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
const elementoResposta = document.querySelector('#resposta')
const inputPergunta = document.querySelector('#inputPergunta')
const buttonPerguntar = document.querySelector('#buttonPerguntar')
const respostas = [
'Certeza!',
'Não tenho tanta certeza.',
'É decididamente assim.',
'Não conte com isso.',
'Sem dúvidas!',
'Pergunte novamente mais tarde.',
'Sim, definitivamente!',
'Minha resposta é não.',
'Você pode contar com isso.',
'Melhor não te dizer agora.',
'A meu ver, sim.',
'Minhas fontes dizem não.',
'Provavelmente.',
'Não é possível prever agora.',
'Perspectiva boa.',
'As perspectivas não são tão boas.',
'Sim.',
'Concentre-se e pergunte novamente.',
'Sinais apontam que sim.'
]
function fazerPergunta() {
if (inputPergunta.value == '') {
alert('Digite sua pergunta!')
return
}
buttonPerguntar.setAttribute('disabled', true)
const pergunta = '<div>' + inputPergunta.value + '</div>'
const totalResposta = respostas.length
const numeroAleatorio = Math.floor(Math.random() * 19)
elementoResposta.innerHTML = pergunta + respostas[numeroAleatorio]
elementoResposta.style.opacity = 1
setTimeout(function () {
elementoResposta.style.opacity = 0
buttonPerguntar.removeAttribute('disabled')
}, 3000)
}