freeCodeCamp Challenge Guide: Create complex multi-dimensional arrays

Create complex multi-dimensional arrays


Hints

Hint 1

  • The first string - deep - must be inserted three levels deep. This means within exactly threes sets of [square-brackets].
let threeLevelArray = [
  "first level",
  ["Two levels deep", ["Three levels deep"]]
];
  • Using this logic insert strings deep , deeper and deepest in the matrix three levels deep, four levels deep and five levels deep respectively.

Solutions

Solution 1 (Click to Show/Hide)
let myNestedArray = [
  // change code below this line
  ["unshift", false, 1, 2, 3, "complex", "nested"],
  ["loop", "shift", 6, 7, 1000, "method"],
  ["concat", false, true, "spread", "array", ["deep"]],
  ["mutate", 1327.98, "splice", "slice", "push", [["deeper"]]],
  ["iterate", 1.3849, 7, "8.4876", "arbitrary", "depth", [[["deepest"]]]]
  // change code above this line
];
Solution 2 (Click to Show/Hide)
let myNestedArray = [
  // Only change code below this line
  'level 1',                   /* myNestedArray[0]             */
  ['level 2'],	               /* myNestedArray[1][0]          */
  [['level 3','deep']],	       /* myNestedArray[2][0][0]       */
  [[['level 4','deeper']]],    /* myNestedArray[3][0][0][0]    */
  [[[['level 5','deepest']]]]  /* myNestedArray[4][0][0][0][0] */
  // Only change code above this line
];
19 Likes