Acho que acertei .... Teria como confirmar? O programa funcionou, mais ainda estou achando que tem alguma coisa errada
<html>
<meta charset="utf-8">
<center>
<h1> Jogo do adivinha</h1>
<h4> Você tem 3 tentativas, porem você esta com sorte, o PC vai ajudar você!</h4>
<p></p><strong> Tenta acerta o número </strong></p>
<input/>
<button> Clique aqui</button>
</center>
</html>
<script>
var segredo = Math.round(Math.random() * 10);
var input = document.querySelector ("input");
var button = document.querySelector ("button");
input.focus();
var tentativa = 1
function verifica (){
if (tentativa >3){
alert ("Que pena você errou!")
}
while (tentativa <=3 ){
if (input.value == segredo){
alert ("Muito bem acertou " + segredo );
return;
} else {
alert ("Quase lá,mais temos uma dica, a diferença é de " + (segredo - input.value));
tentativa ++;
return;
}
}
}
button.onclick = verifica;
</script>