loop for js 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

let str = "";

for (let i = 0; i < 9; i++) {
  str = str + i;
}

console.log(str);
// expected output: "012345678"

Example 3: javascript for loop

for (let count = 0; count < 90; count++) {
	// ...
}

Example 4: loop javascript

//this is javascript
var speed = 100;
setInterval(function() {
//DO SOMETHING THAT REPEATS
},speed);

Example 5: javascript for loop

let my_capacity = 15;
for (let my_var = 0; my_var < my_capacity; my_var++)
{
  console.log(my_var)
}