<script>
        function pulaLinha() {
            document.write("<br>");
        }
        function mostra(frase) {
            document.write(frase);
            pulaLinha();
        }
        function sorteia() {
            return Math.round(Math.random() * 10);
        }
        var numeroPensado = sorteia();
        var tentativas = 1;
        while (tentativas <= 3) {
            var chute = parseInt(prompt("Digite seu chute de 1 a 10: "));
            if (isNaN(chute) || chute > 10 || chute < 1) {
                alert("Digite um valor válido!");
            } else if (chute == numeroPensado) {
                mostra("Uau! Você acertou, pois eu pensei no " + numeroPensado);
            } else {
                alert("Você errou!");
            }
            tentativas++;
        }
        mostra("FIM")
    </script>
 
            