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=0; i<fruits.length; i++) { document.write("<p>" + fruits[i] + "</p>"); } </script> </body> </html>