HTML Compiler Online
Javascript Online Compiler
index.html
Change Theme
Compress code
Format code
Download Code
Clear Code
Copy Code!
RunĀ
ctrl+s or click
Output
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Javascript - for...of loop</title> </head> <body> <h2>Using for...of loop in javascript to iterate through array.</h2> <p id="output"></p> <script> var fruits = ["Apple", "Banana", "Carrot", "Guava", "Orange"]; let i; for (i of fruits) { // i represent 1 value of fruit document.getElementById("output").innerHTML += i + "<br>"; } </script> </body> </html>
RunĀ
x
x