Não consigo achar o erro do loop infinito.
<meta charset="utf-8">>
<input/>
<button>Compare com o meu segredo</button>>
<script>
function sorteia() {
return Math.round(Math.random() * 10)
}
function sorteiaNumeros(quantidade) {
var segredos = [];
var numero = 1;
while (numero <= quantidade) {
var numeroAleatorio = sorteia();
if (numeroAleatorio =! 0) {
var achou = false;
for (var z = 0; z < segredos.length; z++) {
if (segredos[z] == numeroAleatorio) {
achou = true;
break;
}
}
if (achou == false) {
segredos.push(numeroAleatorio);
numero++
}
}
}
return segredos
}
var segredos = sorteiaNumeros(5);
console.log(segredos);
var input = document.querySelector("input");
var button = document.querySelector("button");
input.focus();
function verifica() {
var achou1 = false;
for (var i = 0; i < segredos.length; i++) {
if (input.value == segredos[i]) {
alert("Voce acertou");
var achou1 = true;
break
}
}
if (achou1 == false) {
alert("Errou!")
input.value = "";
input.focus();
}
}
button.onclick = verifica;
</script>>