<meta charset="UTF-8">
<input/>
<button>Compare com o meu segredo</button>
<script>
    function mostra(frase) {
        document.write(frase);
        pulaLinha();
    }
    function sorteia() {
        return Math.round(Math.random() * 10);
    }
    function sorteiaNumeros(quantidade) {
        var segredos = [];
        var numero = 1;
        while( numero <= quantidade) {
            var numeroAleatorio = sorteia();
            var achou = false;
            if(numeroAleatorio !== 0) {
                for (var posicao = 0; posicao < segredos.length; posicao++) {
                    if (segredos[posicao] == numeroAleatorio){
                        achou = true;
                        break;
                    }
                }
                if (achou == false) {
                    segredos.push(numeroAleatorio);
                    numero++;
                }
            }
        }
        return segredos;
    }
    function verifica () {
        var segredos = sorteiaNumeros(5);
        console.log(segredos);
        var input = document.querySelector("input");
        input.focus();
        var achou = false;
        for (var posicao = 0; posicao < segredos.length; posicao++) {
            if (input.value == segredos[posicao]) {
                alert("Bingo!!!");
                achou = true;
                break;
            }
        }
        if (achou == false) {
            alert ("Ñ foi desta vez,tente novamente!!!");        
        }
        input.value = ("");
        input.focus()
    }
    var button = document.querySelector("button"); 
    button.onclick = verifica;
</script> 
             
            