En este ejemplo utilizamos el bucle forof que se usa en Javascript, veamos su sintaxis:
<!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>Bucle forof</title> </head> <body> <h1>Bucle forof</h1> <p>El bucle forof nos sirve sobretodo con arrays y cadenas (strings)</p> <script> let numeros = [10, 20, 30, 40, 50]; let cadena = "Hola Mundo"; for (const elemento of numeros) { console.log(elemento); } console.log(); for (const elemento2 of cadena) { console.log(elemento2); } </script> </body> </html>