I have an object that originally looks like this
{
foo: {
fruit: "watermelon",
vege: "celery",
},
bar: {
fruit: "banana",
candy: "snickers",
drink: "coke",
},
...
}
but want to "flatten" and have it look like this
{
fruit: "banana",
vege: "celery",
candy: "snickers",
drink: "coke",
}
If there's an overlap in the sub-object keys, just overwrite the previous one.
What's a sane way to do this?