for loop javascript when to use them 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 for loop
let my_capacity = 15;
for (let my_var = 0; my_var < my_capacity; my_var++)
{
console.log(my_var)
}