Take the following Javascript Array:
["21587569", "21587570", "21587572", "31856855", "31856854"]
You can visually see that the first 3 items are within a limit of 5 of any other item in that "group", the same can be said for the items at index 3 & 4.
How can I group these "similar" items using Javascript array functions, such as the following output array?
[{"21587569", "21587570", "21587572"},{"31856855", "31856854"}]
The items may not always be presented in order as they are in the example input array.
21587575as well. should it be alone or take a smaller item as well, and how much?