1
respuesta

juego adivinacion mejorado a mi manera

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <h1>ADIVINA ADIVINADOR</h1>
    <script>
        function saltarLinea() {
            document.write("<br>");
            document.write("<br>");
        }

        function imprimir(frase) {
            document.write(frase);
            saltarLinea();
        }


        var intentos = 3;
        var contador = 1;


        while (contador <= intentos) {
            var numeroPensado = Math.round(Math.random() * 10);
            var numeroLanzado = parseInt(prompt('Digite un numero'));

            if (numeroLanzado == numeroPensado) {
                alert('Acertaste el numero');
                break;
            } else {
                if (contador == 1) {
                    alert('No acertaste, intenta nuevamente');
                }
                if (contador == 2) {
                    alert('Ultimo intento, buena suerte!');
                }
                if (contador == 3) {
                    alert('Mala Suerte');
                }

            }

            if (contador == intentos) {
                alert('Perdiste, Gracias por jugar');
            }
            contador++;
        }

        imprimir('Creado por Agustin Baiud');

    </script>
</body>

</html>

ESPERO QUE LES GUSTE

1 respuesta

Hola Miguel

Gracias por compartir tu código, está muy bien felicitaciones.

Si tienes alguna pregunta sobre el contenido de los cursos, estaremos aquí para ayudarte.

Si este post te ayudó, por favor, marca como solucionado ✓. Continúa con tus estudios