1
resposta

Projeto final do curso

alert("Boas vindas ao jogo do número secreto"); let numeroMaximo = 5000; let numeroSecreto = parseInt(Math.random() * numeroMaximo + 1); console.log(numeroSecreto); let chute; let tentativas = 1;

// enquanto chute não for igual ao numero secreto while (chute != numeroSecreto) { chute = prompt (Escolha um número entre 1 e ${numeroMaximo}); //se chute for igual ao numero secreto if (chute == numeroSecreto) { break; } else { if (chute > numeroSecreto) { alert(o número secreto é menor que ${chute}); } else { alert(o número secreto é maior que ${chute}); } //tentativas = tentativas + 1; tentativas++ } } let palavraTentativa = tentativas > 1 ? "tentativas" : "tentativa"; alert(Isso ai! Você descobriu o número secreto ${numeroSecreto} com ${tentativas} ${palavraTentativa}.);

1 resposta

Fábio,

O projeto final merece uma formatação correta

forum