2020-06-30 14:21:26 +05:30

1.6 KiB

id, title, isRequired, challengeType, videoUrl, localeTitle
id title isRequired challengeType videoUrl localeTitle
ab306dbdcc907c7ddfc30830 Steamroller true 5 压路机

Description

展平嵌套数组。您必须考虑不同的嵌套级别。如果卡住,请记得使用Read-Search-Ask 。尝试配对程序。编写自己的代码。

Instructions

Tests

tests:
  - text: '<code>steamrollArray([[[&quot;a&quot;]], [[&quot;b&quot;]]])</code>应返回<code>[&quot;a&quot;, &quot;b&quot;]</code> 。'
    testString: assert.deepEqual(steamrollArray([[["a"]], [["b"]]]), ["a", "b"]);
  - text: '<code>steamrollArray([1, [2], [3, [[4]]]])</code>应该返回<code>[1, 2, 3, 4]</code> 。'
    testString: assert.deepEqual(steamrollArray([1, [2], [3, [[4]]]]), [1, 2, 3, 4]);
  - text: '<code>steamrollArray([1, [], [3, [[4]]]])</code>应该返回<code>[1, 3, 4]</code> 。'
    testString: assert.deepEqual(steamrollArray([1, [], [3, [[4]]]]), [1, 3, 4]);
  - text: '<code>steamrollArray([1, {}, [3, [[4]]]])</code>应返回<code>[1, {}, 3, 4]</code> 。'
    testString: assert.deepEqual(steamrollArray([1, {}, [3, [[4]]]]), [1, {}, 3, 4]);

Challenge Seed

function steamrollArray(arr) {
  // I'm a steamroller, baby
  return arr;
}

steamrollArray([1, [2], [3, [[4]]]]);

Solution

// solution required