for 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
for (let step = 0; step < 5; step++) {
// Runs 5 times, with values of step 0 through 4.
console.log(step);
}
0
1
2
3
4
Example 3: cuando usar for en js
for ([expresion-inicial]; [condicion]; [expresion-final])sentencia