freeCodeCamp/curriculum/challenges/spanish/02-javascript-algorithms-an.../basic-javascript/iterate-with-javascript-whi...

1.6 KiB

id title challengeType videoUrl localeTitle
cf1111c1c11feddfaeb1bdef Iterate with JavaScript While Loops 1 Iterar con JavaScript mientras bucles

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;
mientras (i <5) {
nuestroArray.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

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

// solution required