--- id: 56105e7b514f539506016a5e title: Count Backwards With a For Loop challengeType: 1 videoUrl: '' localeTitle: Contar hacia atrás con un bucle for --- ## Description
Un bucle for también puede contar hacia atrás, siempre que podamos definir las condiciones correctas. Para contar hacia atrás de dos en dos, necesitaremos cambiar nuestra initialization , condition y final-expression . Comenzaremos en i = 10 y haremos un bucle mientras i > 0 . Disminuiremos i en 2 cada bucle con i -= 2 .
var ourArray = [];
para (var i = 10; i> 0; i- = 2) {
nuestroArray.push (i);
}
ourArray ahora contendrá [10,8,6,4,2] . Cambiemos nuestra initialization y final-expression para que podamos contar hacia atrás de dos en dos por números impares.
## Instructions
Empuje los números impares del 9 al 1 a myArray usando un bucle for .
## Tests
```yml tests: - text: Usted debe estar usando una for bucle para esto. testString: 'assert(code.match(/for\s*\(/g).length > 1, "You should be using a for loop for this.");' - text: Deberías estar usando el método de matriz push . testString: 'assert(code.match(/myArray.push/), "You should be using the array method push.");' - text: 'myArray debe ser igual a [9,7,5,3,1] .' testString: 'assert.deepEqual(myArray, [9,7,5,3,1], "myArray should equal [9,7,5,3,1].");' ```
## Challenge Seed
```js // Example var ourArray = []; for (var i = 10; i > 0; i -= 2) { ourArray.push(i); } // Setup var myArray = []; // Only change code below this line. ```
### After Test
```js console.info('after the test'); ```
## Solution
```js // solution required ```