in my project I have to turn a bunch of coordinates to some meaningful two-dimensional array but I really don't know how to do it. Can somebody help?
To explain what I exactly want, let me give an example:
Let's suppose that I have these 2 arrays(the reason that I started from one is because 0 and the last element of my rows are borders):
[[1, 1], [1, 2], [1, 4], [1, 5], [1, 8], [1, 9], [1, 10],[2, 1], [2, 2], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8], [2, 10]]
Let the value inside these coordinates be like [row,col]. And let's say I wan't to match them to generate some sort of two-dimensional array and each of the elements should contain the value '#'. However, for example;
[1, 2], [1, 4]
[2, 2], [2, 4]
If there's a coordinate missing between two of these elements, they should be separated, meaning that there should be two different two-dimensional arrays, being split from that coordinate. In this case, the result should be;
// First two-dimensional array
const firstArray = [
['#','#'],
['#','#']
]
const secondArray = [
['#','#','','','#','#','#'],
['#','#','#','#','#','','#'],
]
In the second array, there are some '' values, but that is because the there are some coordinates missing(for [1, 5] and [1, 8], [1,6] and [1,7] are missing). So that should be considered too.
If you didn't understand please comment under the question me so that I can explain it to you.
How can I come up with the functionality that I'm looking for?