javascrit for loop code example
Example 1: javascript for loop
var colors=["red","blue","green"];
for (let i = 0; i < colors.length; i++) {
console.log(colors[i]);
}
Example 2: javascript iterate through for loop
var myStringArray = ["Hello","World"];
var arrayLength = myStringArray.length;
for (var i = 0; i < arrayLength; i++) {
console.log(myStringArray[i]);
}
Example 3: for of loop syntax javascript
for (let step = 0; step < 5; step++) {
console.log('Walking east one step');
}
Example 4: javascript loop
var items=["a","b","c"];
for(let item of items){
console.log(item)
}