I have data that looks like this:
[{label: "uno", men: 3, kids: 2, womens: 5}, {label: "dos", men: 4, kids: 2, womens: 2}]
At the end of the transformation I would like to have 4 arrays containing the data-fields:
var labels = ["uno", "dos"];
var men = [3, 4];
var kids = [2, 2];
var womens = [5, 2];
I am doing it like that:
var label = [];
var men = [];
var kids = [];
var women = [];
dataArray.forEach(function(data){
label.push(data.label);
men.push(data.men);
kids.push(data.kids);
women.push(data.women);
});
Is there a nicer/shorter way to achieve the same data-transformation? Thanks a lot!