how to print array elements using for loop in javascript code example
Example 1: javascript loop through array
const myArray = ['foo', 'bar'];
myArray.forEach(x => console.log(x));
//or
for(let i = 0; i < myArray.length; i++) {
console.log(myArray[i]);
}
Example 2: javascript loop and array
var array = ["hello","world"];
array.forEach(item=>{
console.log(item);
});