I am working with a nested object structured like this
const data = [
{ id: '1', description: 'desc 1',
data : [
{ id: '5', description: 'desc', number :1 },
{ id: '4', description: 'descip', number :2 } ],
{ id: '2', description: 'desc 2',
data: [
{ id: '5', description: 'desc', number: 3 },
{ id: '4', description: 'descip', number: 4 },
{ id: '2', description: 'descipr', number: 6 }
]},
];
I aim to transform this object using the reduce method and then feed the transformed data into chartjs
data =[
desc : { id: '5', description: { 'desc1' ,'desc2'}, number :{1,3} },
descip: { id: '4', description: { 'desc1' ,'desc2'}, number :{2,4} },
descipr: { id: '2', description: { 'desc2'}, number :{6} }
]
Your assistance on this matter would be greatly appreciated