let str = ""; for (let i = 0; i < 9; i++) { str = str + i; } console.log(str); // expected output: "012345678"
var texts = [ 'a1', 'a2', 'a3', ]; for (var i = 0; i < 3; i++) { console.log(texts[i]); } /* Result a1 a2 a3 */
//this loops through an array, 'cars', and logs each element to the console. for (var i = 0; i < cars.length; i++) { //repeating code here: console.log(cars[i]); }
var texts = [ 'a1', 'a2', 'a3', ]; for (var i = 0; i < texts.length; i++) { console.log(texts[i]); } /* Result a1 a2 a3 */
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
for (let i = 0; i < 9; i++) { str = str + i; }