Freecodecamp: Access Multi-Dimensional Arrays with Indexes

Created on 15 Feb 2016  路  7Comments  路  Source: freeCodeCamp/freeCodeCamp

I was helping a fellow camper out with this one, and feel that the challenge itself could be written or explained better and more in depth.

I asked @QuincyLarson about it in gitter and he suggest that we open an issue here. If I can think of ideas other than explaining it more in depth, I'll comment them in here.

first timers only help wanted

All 7 comments

@SaintPeter do you have any ideas?

I had a lot of trouble with this one too. I don't understand the math that's involved to get the answer of 8. I ended up just putting random numbers in the variable until I got the correct answer. Even then I still don't understand how I got the correct answer.

@ajboilanger I thought the examples would be enough to explain and show how these multi-dimensional arrays work. How were you able to explain this concept to others that was lacking from the challenge itself?

I had same experience as LupDre. It isn't intuitively obvious (to me) how the explanation sets us students up for understanding. For example, what the hell is "outer-most" and subsequent levels?? "When you use brackets to access your array, the first set of bracket refers to the entries in the outer-most array, and each subsequent level of brackets refers to the next level of entries inside." This is not at all clear for first-timers. And the example arr[3][0][1]; // equals 11 is extremely perplexing.

@CaptRat thanks for the feedback on your learning experience. I think the example code could be redone to emphasize how they work. Here's a suggested rewrite:

One way to think of a multi-dimensional array, is as an _array of arrays_. When you use brackets to access your array, the first set of bracket refers to the entries in the outer-most (the first level) array, and each additional pair of brackets refers to the next level of entries inside.

Example

var arr = [
    [1,2,3],
    [4,5,6],
    [7,8,9],
    [[10,11,12], 13, 14]
];
arr[3]; // equals [[10,11,12], 13, 14]
arr[3][0]; // equals [10,11,12]
arr[3][0][1]; // equals 11

Any feedback on how well it explains the concept is welcome.

@erictleung That looks nice.

Anyone wanting to help contribute and fix this issue, below are the lines that need changing. Refer back to my comment above on what needs to be changed.

  • This line needs a slight edit with the bold text I added above. You don't need to add the actual bold tags, I added them there to points out the changes I made.
  • This line needs to be edited so it matches the example I have above.

Please first read the contributing guidelines before taking care of this issue. And feel free to visit the Contributors Help if you have any questions about helping. We're there to help.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ar5had picture ar5had  路  3Comments

itsmikewest picture itsmikewest  路  3Comments

danielonodje picture danielonodje  路  3Comments

Tzahile picture Tzahile  路  3Comments

imhuyqn picture imhuyqn  路  3Comments