-
-
Save Ifmr24/65207d62b0f49b2dfc168f99763bcb8e to your computer and use it in GitHub Desktop.
JS Bucle FOR
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// BUCLE FOR | |
// BUCLE ES UNA ESTRUCTURA DE CONTROL QUE SE REPITE VARIAS VECES | |
// La variable numero sera el maximo de veces que se repetira el bucle | |
var numero = 100; | |
//Variable i sera el contador; mientras i sea menor o igual a numero(100) se repetira; incrementamos la variable i cada vez que se repita | |
for( var i = 1; i <= numero; i++ ){ | |
console.log("Vamos por el numero: " + i ); | |
} | |
//Repasaremos una lista o array con un bucle FOR | |
var autos = ["Toyota","Nissan","Chevrolet","Volvo","BMW"]; | |
//Variable i sera cada indice dentro del array autos | |
for( var i in autos ){ | |
/* | |
Imprimimos la variable autos junto a su lugar en el indice, | |
el bucle lo repetira dependiendo de la cantidad de valores dentro de la lista. | |
*/ | |
console.log(autos[i]); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment