teslariu

while-dowhile

Jul 11th, 2022
1,249
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!DOCTYPE html>
  2. <html>
  3. <body>
  4.  
  5. <h2>Bucle while</h2>
  6. <p id="demo"></p>
  7.  
  8. <h2>Bucle do-while</h2>
  9. <p id="demo2"></p>
  10.  
  11. <script>
  12.     var texto = "";
  13.     var i = 0;
  14.     while (i < 10) {
  15.         texto += "<br>El numero es " + i;
  16.         i++;
  17.     }
  18.     document.getElementById("demo").innerHTML = texto;
  19. </script>
  20.  
  21. <script>
  22.     var otroTexto = ""
  23.     var i = 0;
  24.    
  25.     do {
  26.       otroTexto += "<br>El numero es " + i;
  27.       i++;
  28.     }
  29.     while (i < 10);  
  30.     document.getElementById("demo2").innerHTML = otroTexto;
  31.     </script>
  32.  
  33. </body>
  34. </html>
Advertisement
Add Comment
Please, Sign In to add comment