-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
25 lines (24 loc) · 825 Bytes
/
app.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
alert('Descubra a porra do número secreto');
let numeroSecreto = parseInt(Math.random()*100+1) ;
console.log(numeroSecreto)
let chute = prompt('Escolha um número de 1 a 100');
let tentativas = 1;
//enquanto o chute não for igual o número secreto
while (chute != numeroSecreto)
{chute = prompt('Escolha um número de 1 a 100');
//se o chute for igual ao número secreto
if (chute == numeroSecreto){
break;
} else {
if (chute > numeroSecreto){
alert(`o número secreto é menor ${chute}`)
}
else{
alert(`o número secreto é maior que ${chute}`)
}
//tentativa=tentativa + 1
tentativas++
}
}
let palavraTentativa = tentativas > 1 ? 'tentativas' : 'tentativa'
alert(`Isso ai porra! Você descobriu o número secreto que é ${numeroSecreto}, com ${tentativas} ${palavraTentativa}`);