I have an array and I want to generate an array with hash and inside that hash one more data. I have a data array which is:
[
{
id: 1,
name:"abc"
title:"xyz"
},
{
id: 2,
name:"abc1"
title:"xyz1"
},
]
And I want to generate an output like this:
[
{
type: "column",
dataPoints: [
{y: 1, label: "abc"},
{y: 2 ,label: "xyz"}
]
},
{
type: "column",
dataPoints: [
{y: 1, label: "abc1"},
{y: 2 ,label: "xyz"}
]
}
]
How create this kind of array hash using map or any array loop. I am trying to generate data points for charts. I am looking for best possible solution.