Show Output
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>JavaScript Loop Through an Array Using For-In Loop</title> </head> <body> <script> // An array with some elements var fruits = ["Apple", "Banana", "Mango", "Orange", "Papaya"]; // Loop through all the elements in the array for(var i in fruits) { document.write("<p>" + fruits[i] + "</p>"); } </script> </body> </html>