-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
28 lines (26 loc) · 857 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
26
27
28
alert("Boas vindas ao jogo do número secreto!");
let numeroSecreto = parseInt(Math.random()*10+1);
console.log(numeroSecreto);
let chute = prompt("Escolha um número de 1 a 10");
let tentativas = 1;
//enquanto o chute não for igual ao número secreto
while ( chute != numeroSecreto){
chute = prompt("Escolha um número de 1 a 10");
//se o chute for igual ao núemro secreto
if(chute == numeroSecreto){
break;
} else {
if (chute > numeroSecreto){
alert(`o número secreto é menor que $
{chute}`)
} else{
alert(`o número secreto é menor que $
{chute}`)
}
//tentativas = tentativas + 1
tentativas==
}
}
let palavraTentativa = tentativa > 1 ?
'tentativas' : 'tentativas'
alert(`Isso ai você descobriu o número secreto ${numeroSecreto} com ${tentativas} ${palavraTentativa}`);