Iterating
let newArray = ['a', 'b', 'c', 'd', 'e'];for Loop
for (let i = 0; i < newArray.length; i++) //i increases after each iteration; forces the loop to break once i reaches the value of newArray.length
{
console.log(newArray[i]); //prints the value of the element at index i each iteration
}while Loop
while (let i < newArray.length)
{
console.log(newArray[i]);
i++; //i increases after printing each time
}forEach method
//standard syntax
newArray.forEach(function(index) {
console.log(index);
});
//arrow function
newArray.forEach(index => console.log(index));File Location
Practice
Last updated