Create complex multi-dimensional arrays

Create complex multi-dimensional arrays
0.0 0

#1

Tell us what’s happening:

This is really confused with multi array and I am lost the track… I don’t know which one

However I have looked up at challenge solution but its wrong

let myNestedArray = [
	[
		1, 2, 3, 3, 5, 6, [true, false, false, 12]
	]
];

the console log said
// running test
myNestedArray should have exactly 5 levels of depth
myNestedArray should contain exactly one occurrence of the string “deep” on an array nested 3 levels deep
myNestedArray should contain exactly one occurrence of the string “deeper” on an array nested 4 levels deep
myNestedArray should contain exactly one occurrence of the string “deepest” on an array nested 5 levels deep
// tests completed

Your code so far


let myNestedArray = [
	[
		1, 2, 3, 3, 5, 6, [true, false, false, 12]
	]
];

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-data-structures/create-complex-multi-dimensional-arrays


#2

the question asked us to slove it

  • myNestedArray should contain only numbers, booleans, and strings as data elements
  • myNestedArray should have exactly 5 levels of depth
  • myNestedArray should contain exactly one occurrence of the string “deep” on an array nested 3 levels deep
  • myNestedArray should contain exactly one occurrence of the string “deeper” on an array nested 4 levels deep
  • myNestedArray should contain exactly one occurrence of the string “deepest” on an array nested 5 levels deep
let myNestedArray = [
  // change code below this line
  ['unshift', false, 1, 2, 3, 'complex', 'nested'],
  ['loop', 'shift', 6, 7, 1000, 'method'],
  [
    [
      ['deep'],
      ['deeper'],
      [['deepest']]
    ]
  ]
  // change code above this line
];

lkas;dkfklasdf


#3

Hi @arduino731,

This is the solution:

let myNestedArray = [
  // change code below this line
  // top, or first level - the outer most array
  ['dee'], // an array within an array, 2 levels of depth
  [
    ['deep'], ['dee'] // 2 arrays nested 3 levels deep
  ],
  [
    [
      ['deeper'], ['deepe'] // 2 arrays nested 4 levels deep
    ],
    [
      [
        ['deepest'] // an array nested 5 levels deep
      ]
    ]
  ]
  // change code above this line
];

Just remove the code in challenge and replace my code into your challenge, it will worked probably.

Hope this will help you to pass this challenge, good luck and keep going up :muscle:

Regards,
Ali Mosaad


#4

@ali-admin Instead of just posting the solution, try to give the OP hints. If you do post a full working solution, please blur it out. This allows the OP to figure out more on his/her own before seeing a working solution. The OP will learn more by writing his/her own code instead of copying and pasting.

In the future, if you post a full passing solution to a challenge and have questions about it, please surround it with [spoiler] and [/spoiler] tags on the line above and below your solution code.

Thank you.


#5

Hi @randelldawson,

Thank you for your advice, i will work with your advice in the future.

Regards,
Ali Mosaad


#6

When I see a question like this, I usually try to explain why the code written does not work, which should hopefully point the OP in the correct direction. This accomplishes two things.

  1. It does not just give the answer.

  2. It improves my debugging skills and my ability to break down wrong solutions to others.


#7

Hi @randelldawson,

I think you are right, next help i will explain solutions and make a full depth teaching.

Thank you very much for your great advice again.

Regards,
Ali Mosaad