Here's a straightforward question. I have an array, like this:
let array = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
maxChunkLength = 3;
I am looking to divide this array into multiple arrays as follows:
[[1, 2, 3], [3, 4, 5], [5, 6, 7], [7, 8, 9], [9, 10]]
The key point here is that the last element of each chunk should be the first element of the following chunk.
If anyone has suggestions on the optimal approach to achieve this, please share!