How to get item index in a single-dimension array using row and column?
I have a single-dimension array that contains items from a grid. Each item in the array contains the values of which row and column it occupies in the grid. What I need to do is to obtain the index of said item in the single-dimension array using its row and column. In other words, I need to map the row and column with the index of the item in the single-dimension array. How do I achieve that? [Details] The array is a HTMLCollection containing 64 div elements which are inside another div with display=grid. The grid size (rows, cols) is 8x8. I get said item when it's clicked. I retrieve the row and column of that item in the grid container. [Example] If item's row = 0 and col = 3, the index of that item in the single-dimension array is 3. If row = 1 and col = 1, index must be 19. Thanks in advance.