Is there a way to restructure this data?
const arr = [
{
"name": "a_1",
"v": 1
},
{
"name": "b_1",
"v": 1
},
{
"name": "a_2",
"v": 2
},
{
"name": "b_2",
"v": 3
}
]
into this format?
[{
a: 1,
b: 1
}, {
a: 2,
b: 3
}]
I have attempted using forEach and split('_').pop() to extract the group key from the name, but am struggling with grouping them together.