for loop statement javascript 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: loop javascript
// infinite for loop
for(let i = 1; i > 0; i++) {
// block of code
}
Example 3: javascript for of
const array = ['hello', 'world', 'of', 'Corona'];
for (const item of array) {
console.log(item);
}
Example 4: for javascipt
for (let i = 0; i < 9; i++) {
str = str + i;
}