Create complex multi-dimensional arrays

“level1”,
[“level2”]
[“level2”,[“level3”]]
[“level2”, [[“level3”], “deep”]]
[“level2”, [[[“level3”], “level4”],“deeper”]]
[“level2”, [[[[“level3”], “level4”], “deeper”], “deepest”]]

I feel so sad, I know I have to do something like this but nothing’s working and I get silly errors(as far as I can tell at least) that say I don’t have only numbers, booleans and strings.
But all I have is strings… even if turn one of the strings into a number and another into a bool the same issue…
Of course, the other tests are also wrong but I just don’t get it, how are we counting the levels, is it not with the number of indexes needed?
That’s just sad and it is not the first occasion that I do not understand something.
I think the site overall needs much, much better instructions.
It also needs more repetition so that gradually we get used to things.
So frustrating… I am just going to have to copy-paste the solution and I looked at it and it’s just wrong to my eyes… But regardless, shouldn’t I be able to do it?
That’s just sad :cry:

Don’t feel sad. This is hard stuff. That’s why it pays well. Everyone has things with which they struggle - I know I did/do.

Is this part of an FCC challenge? Maybe we can help you understand it?

I believe it is this one

1 Like

Try watching the CS50X lecture here start at 01:42 time stamp.
It is using a different language (C) but it may help you understand loops.

@impossible If you want some help please show exactly the current state of your code. Of the top of my head, I see that you are missing some commas at the ends of the lines. You also have “deeper” twice - you’re only supposed to have it once. You’re also a little off on your levels:

[“level2”,[“level3”]]
[“level2”, [[“level3”], “deep”]]

Notice on these two lines that “level3” is on different level in each - there is an extra set of brackets in the second. The first one is right.

This can be confusing. It’s a bit of a brain teaser of a problem. It’s intentionally a little confusing.

1 Like

let myNestedArray = [
// Only change code below this line
[‘unshift’, false, 1, 2, 3, ‘complex’, ‘nested’],
[‘loop’, [‘deep’, 6, 7, 1000, ‘method’]],
[‘concat’, [false, [true, ‘deeper’, ‘array’]]],
[‘mutate’,[ 1327.98,[‘splice’,[ true, ‘deepest’, ‘push’]]]],
[‘iterate’, 1.3849, 7, ‘8.4876’, ‘arbitrary’, ‘depth’]
// Only change code above this line
];

I am not sure why, but trying it again worked…(above is what I tried and worked)
It was only slightly tricky, as I was expecting it would have been the first time.
I certainly didn’t improve anything from the first time, my understanding of it has stayed the same…

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.