I'll try to be brief in the description. I have, for example, two arrays. One of them has 6 indexes and the other 7.
I need to get the first 5 indexes of each array and perform a function, then I have to get the remaining indexes from that array and perform another function. If the remaining remaining indexes are greater than 5, I have to get the 5 and then the others, and so on.
The checks, I have no problem, but I'm having trouble finding a way to fit the functions into each of the indexes
Edit: I tried something like this:
for (let i = 0; i < array.length; i++){
if (i === 5) {
// executa função para mod de 5
} else if (i > 5) {
if (i % 5 === 0) {
// executa função para maiores do 5, que formam outro conjunto de 5
} else {
// executa função para maiores do 5, mas que não formam um novo conjunto de 5
}
}
The problem is that in addition to these numerous ifs, I have not found a way for, at every function within the ifs, to use only the remaining indexes for the function. I need to get into a certain index, pause, do the function, and go to the next indexes, do the checking, and perform other functions.
To illustrate better, in the image I have two arrays, one on the left side with 6 indexes, containing the blocks and another one on the right side, with 7 indexes, containing the blocks. The function must first call sets of 5 blocks to go to ground, then sets that do not have 5 remaining indices in the array.