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.4 KiB

id, title, challengeType, videoUrl, forumTopicId, dashedName
id title challengeType videoUrl forumTopicId dashedName
56105e7b514f539506016a5e Count Backwards With a For Loop 1 https://scrimba.com/c/c2R6BHa 16808 count-backwards-with-a-for-loop

--description--

A for loop can also count backwards, so long as we can define the right conditions.

In order to count backwards by twos, we'll need to change our initialization, condition, and final-expression.

We'll start at i = 10 and loop while i > 0. We'll decrement i by 2 each loop with i -= 2.

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

ourArray will now contain [10,8,6,4,2]. Let's change our initialization and final-expression so we can count backward by twos by odd numbers.

--instructions--

Push the odd numbers from 9 through 1 to myArray using a for loop.

--hints--

You should be using a for loop for this.

assert(/for\s*\([^)]+?\)/.test(code));

You should be using the array method push.

assert(code.match(/myArray.push/));

myArray should equal [9,7,5,3,1].

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

--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 = 9; i > 0; i -= 2) {
  myArray.push(i);
}