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

id, title, challengeType, videoUrl, localeTitle
id title challengeType videoUrl localeTitle
56bbb991ad1ed5201cd392cd Manipulate Arrays With shift() 1 使用shift操纵数组

Description

pop()总是删除数组的最后一个元素。如果你想删除第一个怎么办?这就是.shift()用武之地。它就像.pop()一样工作,除了它删除了第一个元素而不是最后一个元素。

Instructions

使用.shift()函数从myArray删除第一项将“shift off”值分配给removedFromMyArray

Tests

tests:
  - text: '<code>myArray</code>现在应该等于<code>[[&quot;dog&quot;, 3]]</code> 。'
    testString: assert((function(d){if(d[0][0] == 'dog' && d[0][1] === 3 && d[1] == undefined){return true;}else{return false;}})(myArray));
  - text: '<code>removedFromMyArray</code>应该包含<code>[&quot;John&quot;, 23]</code> 。'
    testString: assert((function(d){if(d[0] == 'John' && d[1] === 23 && typeof removedFromMyArray === 'object'){return true;}else{return false;}})(removedFromMyArray));

Challenge Seed

// Example
var ourArray = ["Stimpson", "J", ["cat"]];
var removedFromOurArray = ourArray.shift();
// removedFromOurArray now equals "Stimpson" and ourArray now equals ["J", ["cat"]].

// Setup
var myArray = [["John", 23], ["dog", 3]];

// Only change code below this line.
var removedFromMyArray;

After Test

console.info('after the test');

Solution

// solution required