js for loop
snippet in javascript

javascript for loop

user9726

var colors=["red","blue","green"];
for (let i = 0; i < colors.length; i++) { 
  console.log(colors[i]);
}

javascript for loop

user4431

for (var i; i < 10; i++) {
  
}

js for loop

user2140

var i; //defines i
for (i = 0; i < 5; i++) { //starts loop
  console.log("The Number Is: " + i); //What ever you want
}; //ends loop
//Or:
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);
//They do the same thing!
//Hope I helped!

javascript loop

user8378

let array = ['Item 1', 'Item 2', 'Item 3'];

array.forEach(item => {
	console.log(item); // Logs each 'Item #'
});

js for loop

user8342


  text += cars[0] + "<br>"; 
text += cars[1] + "<br>"; 

 text += cars[2] + "<br>"; 
text += cars[3] + "<br>"; 

 text += cars[4] + "<br>"; 
text += cars[5] + "<br>";
 

js for loop

user7107


  var i;
for (i = 0; i < cars.length; i++) { 
  text += cars[i] + "<br>";

 }