hello everyone hoping you are well, I have a question about how to convert an array in js
I have the following array:
[
{
id:1
L: 10,
XL: 20
},
{
id:2
L: 40,
XL: 50
}
]
and I need it to be like this:
[
{
id:1
name: L,
value: 10
},
{
id:1
name: XL,
value: 20
},
{
id:2
name: L,
value: 40
},
{
id:2
name: XL,
value: 50
}
]
Thanks for the help.
I am using react, so, any solution with js or react it will great.
id:1needs a comma after it. Should help anyone doing a copy/paste to help solve.