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.
@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-dimensionalarray, 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.
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.