folks, I faced with a problem. I have a huge array with objects. And I need to transform it into a specific array with merging inner properties.
I have a source array
const srcArr = [
{
"id": 2142,
"time": 1579111185330,
"rpm": 0,
"speed": 0,
},
{
"id": 435345,
"time": 1579111186340,
"rpm": 1,
"speed": 2,
},
{
"id": 34636,
"time": 1579111187340,
"rpm": 2,
"speed": 4,
}];
And I need on output array like this, excluding key 'id'.
const outArr = [
{
title: "time",
data: [1579111185330, 1579111186340, 1579111187340]
},
{
title: "rpm",
data: [0, 1, 2],
},
{
title: "speed",
data: [0, 2, 4]
}
]
What should I use? Reduce? map?