Can you provide me with some assistance in JavaScript on how to extract multiple columns from a two-dimensional array similar to the example below?
Array = [
[1, 2, 3, 4],
[5, 6, 7, 8],
[9,10,11,12],
];
I have come across methods like forEach or map that allow extracting one column at a time. Is it possible to nest these methods to extract multiple specific columns based on their index?
For instance, if I want columns 1, 2, and 4 as output.
Output = [
[1, 2, 4],
[5, 6, 8],
[9, 10, 12],
];
UPDATE:
Another challenge I am facing is removing any row where Array[i][1] equals 0 or is empty.
If we introduce additional elements into the array...
Array = [
[1, 2, 3, 4],
[5, 6, 7, 8],
[9, 10, 11, 12],
[13, 0, 15, 16],
[17, , 19, 20],
[21, 22, 23, 24],
];
The desired output should be...
Output = [
[1, 2, 4],
[5, 6, 8],
[9, 10, 12],
[21, 22, 24],
];