I am having a bit of an issue and hoping someone can help. I am only a beginner at JS so this might have a really simple answer that is going over my head.
I have a grid that can be dynamically created based on user specified rows and columns. I have an array of row numbers and an array of col numbers and attributed an ID to each member using this formula:
index = (maxcols * rownumber) + col;
I have then added an ID to each member of the grid, resulting to something like this:
1 2 3
4 5 6
7 8 9
Basically what I am trying to find is the value of every member of a column and add that to its own array. So in this case the answer might be
column1 [1,4,7];
column2 [2,5,8];
column3 [3,6,9];
The result im going for is to allow me to find the relative column just by having the member ID. Any push in the right direction would be fantastic. Thanks in advance!
If I understand correctly, you can do this:
Then loop through all indexes and add to the columnsValues[foundCol] your value.
Does this help ?