Ejemplo 1: js para bucle
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!
Ejemplo 2: javascript para bucle
for (var i; i < 10; i++) {
}
Ejemplo 3: javascript anidado para bucle
// Basic Javascript Nested Loop / 2D Array
for (var x = 0; x < 10; x++) {
for (var y = 0; y < 10; y++) {
console.log("x: " + x + ", y: " + y);
}
}
Ejemplo 4: javascipr para de
const array1 = ['a', 'b', 'c'];
for (const element of array1) {
console.log(element);
}
// expected output: "a"
// expected output: "b"
// expected output: "c"
Ejemplo 5: for in loop javascript
var person = {"name":"taylor","age":31};
for (property in person) {
console.log(property,person[property]);
}
//name taylor
//age 31
Ejemplo 6: javascript para bucle
var colors=["red","blue","green"];
for (let i = 0; i < colors.length; i++) {
console.log(colors[i]);
}
¡Haz clic para puntuar esta entrada!
(Votos: 0 Promedio: 0)