<input type="text">
<button> Verificar </button>
<script>
var secrets = []
secrets.length = 5
var input = document.querySelector("input")
input.focus()
function definirNumeros(){
for(var i = 0; i<secrets.length; i++){
secrets[i] = Math.round(Math.random() *10);
}
}
function mirar(){
var flag = false;
for( var secret of secrets){
if(parseInt(input.value) == secret ){
alert("Acertaste!" + "El numero era : " + secret)
flag = true;
break;
}else flag = false;
}
if(!flag)
alert("nada")
input.value = ""
input.focus()
}
definirNumeros();
var button = document.querySelector("button")
button.onclick = mirar;
</script>