Kristofer Koishigawa b3213fc892 fix(i18n): chinese test suite (#38220)
* fix: Chinese test suite

Add localeTiltes, descriptions, and adjust test text and testStrings to get the automated test suite working.

* fix: ran script, updated testStrings and solutions
2020-03-03 18:49:47 +05:30

1.8 KiB
Raw Blame History

id, title, challengeType, videoUrl, localeTitle
id title challengeType videoUrl localeTitle
56105e7b514f539506016a5e Count Backwards With a For Loop 1 用For循环向后计数

Description

只要我们可以定义正确的条件for循环也可以向后计数。为了向后计数两次我们需要更改initialization conditionfinal-expression 。我们将从i = 10开始并在i > 0循环。我们将递减i 2每个回路与i -= 2
var ourArray = [];
forvar i = 10; i> 0; i- = 2{
ourArray.push;
}
ourArray现在包含[10,8,6,4,2] 。让我们改变initializationfinal-expression这样我们就可以向后计数两位奇数。

Instructions

使用for循环将奇数从9到1推送到myArray

Tests

tests:
  - text: 你应该为此使用<code>for</code>循环。
    testString: assert(code.match(/for\s*\(/g).length > 1);
  - text: 你应该使用数组方法<code>push</code> 。
    testString: assert(code.match(/myArray.push/));
  - text: '<code>myArray</code>应该等于<code>[9,7,5,3,1]</code> 。'
    testString: assert.deepEqual(myArray, [9,7,5,3,1]);

Challenge Seed

// Example
var ourArray = [];

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

// Setup
var myArray = [];

// Only change code below this line.

After Test

console.info('after the test');

Solution

// solution required