let numbMaxino = 1000; let numb; let tentativas = 1; let numbSecreto = parseInt(Math.random() * numbMaxino + 1);
while(numb != numbSecreto){ // console.log('O numb é ' + numbSecreto); teste
numb = parseInt(prompt('Escolhaum número entre 1 e 1000'));
if(numbSecreto == numb){
acertou();
break
} else {
if(numb > numbSecreto){
console.log(`O núemro ${numb} é maior que o número secreto`);
} else {
console.log(`O número ${numb} é menor que o número secreto`);
}
tentativas++;
}
}
function acertou(){
let palavraTentativa = tentativas > 1 ? 'Tentativas' : 'Tentativa';
console.log(Parabens! voce acertou, o numb secreto é ${numbSecreto}, foram ${tentativas} ${palavraTentativa} para acertar
);
}