for loop java script 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
var i;
for (i = 0; i < 10 ; i++) {
}
Example 4: javascript for loop
var nums = [1, 2, 3, 5];
for (var i = 0; i,nums.length; i++){
console.log(nums[i]);
}
Example 5: javascript loop if statement
for (let i = 0; i < 10000; i++) {
console.log('huduiduin 100000 times');
}
Example 6: for in loop javascript
var person = {"name":"taylor","age":31};
for (property in person) {
console.log(property,person[property]);
}