1.7 KiB
1.7 KiB
id | title | localeTitle | challengeType |
---|---|---|---|
cf1111c1c11feddfaeb1bdef | Iterate with JavaScript While Loops | Iterar con JavaScript mientras bucles | 1 |
Description
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 = [];Intentemos que funcione un bucle while empujando los valores a una matriz.
var i = 0;
while(i < 5) {
ourArray.push(i);
i++;
}
Instructions
myArray
usando un while
de bucle.
Tests
tests:
- text: Usted debe utilizar un <code>while</code> de bucle para esto.
testString: 'assert(code.match(/while/g), "You should be using a <code>while</code> loop for this.");'
- text: ' <code>myArray</code> debe ser igual a <code>[0,1,2,3,4]</code> .'
testString: 'assert.deepEqual(myArray, [0,1,2,3,4], "<code>myArray</code> should equal <code>[0,1,2,3,4]</code>.");'
Challenge Seed
// Setup
var myArray = [];
// Only change code below this line.
After Test
console.info('after the test');
Solution
var myArray = [];
var i = 0;
while(i < 5) {
myArray.push(i);
i++;
}