Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Challenge [Access MultiDimensional Arrays With Indexes] Solving Bug #10126

Closed
Pablo152 opened this issue Aug 7, 2016 · 10 comments
Closed

Challenge [Access MultiDimensional Arrays With Indexes] Solving Bug #10126

Pablo152 opened this issue Aug 7, 2016 · 10 comments
Assignees
Labels
help wanted Open for all. You do not need permission to work on these.

Comments

@Pablo152
Copy link

Pablo152 commented Aug 7, 2016

Challenge Access MultiDimensional Arrays With Indexes
has an issue.

User Agent is: Mozilla/5.0 (Windows NT 10.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.82 Safari/537.36.
Please describe how to reproduce this issue, and include links to screenshots if possible.
I just used myData = 4 + 4 to get myData = 8 and i solved the challenge that way, if i'm not wrong that's a bug soo...

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];
myData = 4 + 4;
@erictleung
Copy link
Member

@Pablo152 thanks for the issue. You are correct, this is a bug of sorts. Mmm to catch this kind of code, it might be difficult. We could add in two tests:

  1. The default code is var myData = myArray[0][0]; so we could check that they at least change the zeros to something else.
  2. Check that there is no myData = <some number> i.e. a regex for /myData = \d/ or something similar.

cc/ @FreeCodeCamp/issue-moderators

@erictleung erictleung added the status: discussing Under discussion threads. Closed as stale after 60 days of inactivity. label Aug 7, 2016
@BKinahan
Copy link
Contributor

BKinahan commented Aug 7, 2016

@erictleung One or both of those tests could be combined with the You should be using bracket notation to read the value from myArray test to avoid adding clutter to the test message area, since they target the same condition.

@QuincyLarson
Copy link
Contributor

@erictleung I agree with @BKinahan - as we add more tests to address various corner cases that come up, we tuck these behind as few tests as possible to avoid intimidating campers with a wall of tests.

@erictleung
Copy link
Member

@QuincyLarson @BKinahan sounds good! I think we can just add to the You should be using bracket notation to read the value from myArray test with checking that the bracket is not myArray[0][0]. That should be sufficient to catch this corner case.

@erictleung erictleung added help wanted Open for all. You do not need permission to work on these. tests and removed status: discussing Under discussion threads. Closed as stale after 60 days of inactivity. labels Aug 8, 2016
@dhcodes
Copy link
Contributor

dhcodes commented Aug 11, 2016

@erictleung I think we need both your test above and the aforementioned regex for /myData = \d/ because I can set myData = [2][2]; and still run the nefarious code myData = 4+4 to pass the challenge. If you agree I'll try to update the test to check for both a change of myData[0][0] and the regex.

@erictleung
Copy link
Member

@dhcodes sounds reasonable. As @QuincyLarson has mentioned, try to minimize the number of tests we need to add, if any. So for regex looking for /myData = \d/ wouldn't cover the case of myData = 4 + 4 so see if you can account for that as well. Thanks!

@BerkeleyTrue BerkeleyTrue added the status: waiting review To be applied to PR's that are ready for QA, especially when additional review is pending. label Aug 14, 2016
@BKinahan
Copy link
Contributor

@dhcodes said he wasn't working on this, so I grabbed it up 😄

@erictleung erictleung removed the status: waiting review To be applied to PR's that are ready for QA, especially when additional review is pending. label Sep 4, 2016
@AaronOB7
Copy link

While the 4+4 solution does solve the challenge, the correct way to solve based on the directions,"using bracket notation select an element from myArray such that myData is equal to 8", would 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 = myArray[2][1];

@AaronOB7
Copy link

myArray[2][1];

@vasiliaskid
Copy link

nice topic that i learn,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Open for all. You do not need permission to work on these.
Projects
None yet
Development

No branches or pull requests

8 participants