javascript iterate over array but also show index code example
Example 1: iterate through array javascript
var myStringArray = ["Hello","World"];
var arrayLength = myStringArray.length;
for (var i = 0; i < arrayLength; i++) {
console.log(myStringArray[i]);
//Do something
}
Example 2: how to iterate through an array in javascript
const array = ["one", "two", "three"]
array.forEach(function (item, index) {
console.log(item, index);
});