I would like to split nested arrays into groups of 3 (in javascript):
e.g.
let array = [[123],[456],[789],[321],[654],[987]];
I would like split this into a new nested array, i.e.
new_array = [
[
[123],[456],[789]
]
[
[321],[654],[987]
]
]
let array = [[123],[456],[789],[321],[654],[987]];
let new_arr = [];
for (i=0; i<array.length; i+2){
new_arr.push(array[i]);
i++;
new_arr.push(array[i]);
i++;
}
When I log this out to the console, there is no grouping, it just added all the nested array to a new array.