Home
<!DOCTYPE html> <html> <body> <h1>Demo: for loop</h1> <p id="p0"></p> <p id="p1"></p> <p id="p2"></p> <p id="p3"></p> <p id="p4"></p> <script> var arr = [10, 11, 12, 13, 14]; for (var i = 0; i < 5; i++) { document.getElementById("p" + i).innerHTML = arr[i]; } </script> </body> </html>
Result: