Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4.     <title>Ejercicio 1</title>
  5.     <script type="text/javascript">
  6.        
  7.         var aleatorio = Math.floor((Math.random() * 100) + 1);
  8.         var count = 0;
  9.         do {
  10.             var numero = parseInt(prompt("Introduce el numero"));
  11.             if (numero > aleatorio) {
  12.                 alert("Te has pasado, prueba de nuevo!");
  13.                 count += 1;
  14.             } else if (numero < aleatorio) {
  15.                 alert("Es demasiado pequeno!");
  16.                 count +=1;
  17.             } else {
  18.                 alert("Impresionante, has acertado en: " + count + " intentos!");
  19.                 break;
  20.             }
  21.         }
  22.         while (numero != aleatorio);
  23.  
  24.     </script>
  25. </head>
  26. <body>
  27.  
  28. </body>
  29. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement