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
Raw Blame History

id, title, challengeType, videoUrl, forumTopicId, dashedName
id title challengeType videoUrl forumTopicId dashedName
56104e9e514f539506016a5c 使用 For 循环遍历数组的奇数 1 https://scrimba.com/c/cm8n7T9 18212 iterate-odd-numbers-with-a-for-loop

--description--

for循环可以按照我们指定的顺序来迭代通过更改我们的计数器,我们可以按照偶数顺序来迭代。

初始化i = 0,当i < 10的时候继续循环。

i += 2i每次循环之后增加2。

var ourArray = [];
for (var i = 0; i < 10; i += 2) {
  ourArray.push(i);
}

循环结束后,ourArray的值为[0,2,4,6,8]。 改变计数器,这样我们可以用奇数来数。

--instructions--

写一个for循环,把从 1 到 9 的奇数添加到myArray

--hints--

你应该使用for循环。

assert(code.match(/for\s*\(/g).length > 1);

myArray应该等于[1,3,5,7,9]

assert.deepEqual(myArray, [1, 3, 5, 7, 9]);

--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 = [];
for (var i = 1; i < 10; i += 2) {
  myArray.push(i);
}