Oliver Eyton-Williams ee1e8abd87
feat(curriculum): restore seed + solution to Chinese (#40683)
* feat(tools): add seed/solution restore script

* chore(curriculum): remove empty sections' markers

* chore(curriculum): add seed + solution to Chinese

* chore: remove old formatter

* fix: update getChallenges

parse translated challenges separately, without reference to the source

* chore(curriculum): add dashedName to English

* chore(curriculum): add dashedName to Chinese

* refactor: remove unused challenge property 'name'

* fix: relax dashedName requirement

* fix: stray tag

Remove stray `pre` tag from challenge file.

Signed-off-by: nhcarrigan <nhcarrigan@gmail.com>

Co-authored-by: nhcarrigan <nhcarrigan@gmail.com>
2021-01-12 19:31:00 -07:00

1.2 KiB

id, title, challengeType, videoUrl, forumTopicId, dashedName
id title challengeType videoUrl forumTopicId dashedName
cf1111c1c11feddfaeb1bdef while 循环 1 https://scrimba.com/c/c8QbnCM 18220 iterate-with-javascript-while-loops

--description--

你可以使用循环多次执行相同的代码。

我们将学习的第一种类型的循环称为 "while" 循环,因为它规定,当 "while" 条件为真,循环才会执行,反之不执行。

var ourArray = [];
var i = 0;
while(i < 5) {
  ourArray.push(i);
  i++;
}

在上面的代码里,while 循环执行 5 次把 0 到 4 的数字添加到 ourArray 数组里。

让我们通过 while 循环将值添加到数组中。

--instructions--

通过一个while循环,把从 0 到 4 的值添加到myArray中。

--hints--

你应该使用while循环。

assert(code.match(/while/g));

myArray应该等于[0,1,2,3,4]

assert.deepEqual(myArray, [0, 1, 2, 3, 4]);

--seed--

--after-user-code--

if(typeof myArray !== "undefined"){(function(){return myArray;})();}

--seed-contents--

// Setup
var myArray = [];

// Only change code below this line

--solutions--

var myArray = [];
var i = 5;
while(i >= 0) {
  myArray.push(i);
  i--;
}