--- id: cf1111c1c11feddfaeb1bdef title: Iterate with JavaScript While Loops localeTitle: Iterar con JavaScript mientras bucles challengeType: 1 --- ## Description
Puede ejecutar el mismo código varias veces utilizando un bucle. El primer tipo de bucle vamos a aprender se llama un " while " bucle porque funciona "mientras que" una condición especificada es verdadera y se detiene una vez que la condición ya no es cierto.
var ourArray = [];
var i = 0;
while(i < 5) {
  ourArray.push(i);
  i++;
}
Intentemos que funcione un bucle while empujando los valores a una matriz.
## Instructions
Empuje los números de 0 a 4 para myArray usando un while de bucle.
## Tests
```yml tests: - text: Usted debe utilizar un while de bucle para esto. testString: 'assert(code.match(/while/g), "You should be using a while loop for this.");' - text: ' myArray debe ser igual a [0,1,2,3,4] .' testString: 'assert.deepEqual(myArray, [0,1,2,3,4], "myArray should equal [0,1,2,3,4].");' ```
## Challenge Seed
```js // Setup var myArray = []; // Only change code below this line. ```
### After Test
```js console.info('after the test'); ```
## Solution
```js var myArray = []; var i = 0; while(i < 5) { myArray.push(i); i++; } ```