I have an array like this:
var products = [
['date1','prod1',1,2],
['date2','prod2',3,4],
['date3','prod3',5,6],
['date4','prod4',7,8],
['date5','prod5',9,0]
];
And need to pull the integers out of the array and format it like this:
var newProductsArray = [[1,3,5,7,9],[2,4,6,8,0]];
It needs to be able to be dynamic and expand because the products
array will have more "columns".
I have this code but it's doing it backwards and can't figure out how to loop through and just break up the arrays. I am sure it's something simple I'm missing.
var metricStartPosition = 2;
var dataSetInnerArray = [];
var dataSetArray = [];
for (var i = 0; i < array.length; i++) {
for (var k = metricStartPosition; k < array[i].length; k++) {
dataSetInnerArray.push(array[i][k]);
};
dataSetArray.push(dataSetInnerArray);
dataSetInnerArray = [];
};