No final o console mostra a frase" Unexpected end of input "
<meta charset="utf-8">
<input/>
<br>
<button>Compara</button>
<script>
function sorteia() {
return Math.round(Math.random() * 10)
}
function sorteiaNumero(quantidade) {
var segredos=[];
var numero=1
while(numero<=quantidade) {
var numeroAleatorio=sorteia()
if (numeroAleatorio !== 0) {var achou=false
for (var posição=0; posição<segredos.length;posição++ ) {
if (segredos[posição]==numeroAleatorio) {
achou=true
break;}
if (achou==false) { segredos.push(sorteia());
numero++;
}
}
}
return segredos;
}
var segredos=sorteiaNumero(5);
console.log(segredos)
var input=document.querySelector("input");
input.focus();
function verifica() {
var achou=false;
for (var posicao = 0; posicao < segredos.length ; posicao++) {
if (input.value==segredos[posicao]) {alert("Você ACERTOU!! ");
achou=true;
break;}
}
if (achou==false) {alert("Você ERROU!!!!!! " );}
input.value="";
input.focus();
}
var button=document.querySelector("button");
button.onclick=verifica;
</script>