how to make iteration in javascript array code example
Example 1: how to iterate array in javascript
array = [ 1, 2, 3, 4, 5, 6 ];
//set variable//set the stop count // increment each loop
for (let i = 0; i < array.length ;i++) {
array[i] //iterate through each index.
//add the intructions you would like to perform.
// add any method to array[
}
Example 2: JavaScript Array Iteration Methods
var txt = "";
var numbers = [45, 4, 9, 16, 25];
numbers.forEach(myFunction);
function myFunction(value, index, array) {
txt = txt + value + "<br>";
}