for in javscript 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 (var i; i < 10; i++) {
}
Example 4: for in javascript
const object = {a: 1, b: 2, c: 3};
for (const property in object) {
console.log(`${property}: ${object[property]}`);
}
Example 5: js for
for (let step = 0; step < 5; step++) {
console.log(step);
}
0
1
2
3
4
Example 6: javascript for loop
let my_capacity = 15;
for (let my_var = 0; my_var < my_capacity; my_var++)
{
console.log(my_var)
}