I have a situation where I get the data in an array and I have to convert that to multiple arrays... Like Matrix.
const array = [1,2,3,4,5,6,7,8,9]
the output should be:
[[1,3],[2,4],[5,7],[6,8],[9]]
this is what I have so far:
let i = 0;
const add = [];
while (i < list.length) {
add.push([list[i], list[i + 2]]);
i = i + 1;
}
return add;