Challenge Access MultiDimensional Arrays With Indexes has an issue.
User Agent is: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.94 Safari/537.36
.
Please describe how to reproduce this issue, and include links to screenshots if possible.
My code:
// Setup
var myArray = [[1,2,3], [4,5,6], [7,8,9], [[10,11,12], 13, 14]];
// Only change code below this line.
var myData = myArray[0][0] + myArray[2][0];
I think the code used to validate the answer in this challenge has a bug.
Could you please investigate.
Huh. Guess we need to specify that correct code is expected to access only one value from the array rather than using arithmetic operators to combine multiple values.
That, or perhaps populate the array with strings instead of numbers and adjust the tests to match.
var myArray = [['1','2','3'], ['4','5','6'], ['7','8','9'], [['10','11','12'], '13', '14']];
Any reasons why that's a bad solution?
@JAWL Stop what? You may need to adjust your notification settings.
@BKinahan I agree that when read in a certain way, you can interpret the instructions as to get the value 8 in any way you want.
My suggestion on what the instructions should read is:
Using bracket notation, read from
myArray
to select the element8
so thatmyData
will equal8
.
And an extra test can also be added to check for the use of only one accessed value. Any suggestions on a better rewrite are welcome.
My suggestion for the instructions is:
Using bracket notation select an element from
myArray
such that myData is equal to 8.
If this instruction is worthwhile I'll change it and post a PR soon.
After reading the above suggestions, I was able to pass the challenge by submitting:
var myData = myArray[2][1];
So as @pranayberry suggested, the instructions should be change to
Using bracket notation select an element from myArray such that myData is equal to 8.
In the editor, the code should be:
// Setup
var myArray = [[1,2,3], [4,5,6], [7,8,9], [[10,11,12], 13, 14]];
// Only change code below this line.
var myData = "Eneter your number (bracket notation) here"
Thanks for your help.
removed solution by mod
I am new to coding and this challenge like a lot of them is still so vague as to what it is we are doing ? i am not the only person that feels this way either.
removed solution by mod
I see the answer but how did u guys get that?
i have never been more confused, why is the solution 2, 1??
How [2][1] equals 8. Can anyone break it down?
For me, this video explanation helped to figure out why [2][1]: https://youtu.be/9glEVOTrSYo
var myArray = [[1,2,3], [4,5,6], [7,8,9], [[10,11,12], 13, 14]];
// Only change code below this line.
var myData = myArray[2][1];
Quick Explanation:
The code above is setting the variable myData to target the third array within the nested array:
[2] = [7,8,9]
[1] = [8]
You target the third array and you only want the second # within that array; which is the number 8.
Thank you davidgsilva for solution. Instructions were to target all three arrays which is why it was confusing.
Most helpful comment
After reading the above suggestions, I was able to pass the challenge by submitting:
var myData = myArray[2][1];
So as @pranayberry suggested, the instructions should be change to
In the editor, the code should be:
// Setup
var myArray = [[1,2,3], [4,5,6], [7,8,9], [[10,11,12], 13, 14]];
// Only change code below this line.
var myData = "Eneter your number (bracket notation) here"
Thanks for your help.