Within my javascript code, I am working with an object structure like this:
let obj=
{
a: {
a1: [5,5],
a2: [6,6]
},
b: {
a1: [7,7],
a2: [8,8]
},
c: {
a1: [9,9],
a2: [3,3]
}
}
The goal is to transform it into an array structured as follows:
let arr =
[
{
name: 'a1',
a: [5,5],
b: [7,7],
c: [9,9]
},
{
name: 'a2',
a: [6,6],
b: [8,8],
c: [3,3]
}
]
My attempt to achieve this with Object.entries(obj).map(([key, value]) => ({key,value})) didn't give me the desired structure. Any insights on how to reconfigure it would be greatly appreciated.
Thank you!