1.5 KiB
1.5 KiB
id, title, challengeType, videoUrl, localeTitle
id | title | challengeType | videoUrl | localeTitle |
---|---|---|---|---|
cf1111c1c11feddfaeb1bdef | Iterate with JavaScript While Loops | 1 | 在循环时使用JavaScript进行迭代 |
Description
while
”循环,因为它在“while”运行时指定的条件为true,并且一旦该条件不再为真就停止。 var ourArray = [];让我们尝试通过将值推送到数组来实现while循环。
var i = 0;
而(i <5){
ourArray.push(ⅰ);
我++;
}
Instructions
while
循环将数字0到4推送到myArray
。 Tests
tests:
- text: 你应该使用<code>while</code>循环。
testString: 'assert(code.match(/while/g), "You should be using a <code>while</code> loop for this.");'
- text: '<code>myArray</code>应该等于<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