I need to flatten an array where each item contains a nested object, as below:
[
{
a: "x",
b: { b1: "x1", b2: "x2"}
},
{
a: "y",
b: { b1: "y1", b2: "y2"}
}
]
to
[
{
a: "x",
b1: "x1",
b2: "x2"
},
{
a: "y",
b1: "y1",
b2: "y2"
}
]
This here is the closest to what I'm looking for https://stackoverflow.com/a/33037683/4217097 However, I'm not sure how to use that solution for an array, as it only return the last item of the array when I tried applying it.