javascript for statement 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: js for loop
var i;
for (i = 0; i < 5; i++) {
console.log("The Number Is: " + i);
};
console.log("The Number Is: " + 0);
console.log("The Number Is: " + 1);
console.log("The Number Is: " + 2);
console.log("The Number Is: " + 3);
console.log("The Number Is: " + 4);
Example 3: javascript for loop
for (let count = 0; count < 90; count++) {
}
Example 4: javascript loop through array
const array1 = ['a', 'b', 'c'];
array1.forEach(element => console.log(element));
Example 5: js for loops
let i;
for (i = 0; i < 6; ++i) {
console.log("Hello");
}
Example 6: for loop in javascript
For printing 0 to 9
you can write like below also
var i;
for (i = 0; i < 10; i++) {
console.log(i);
}