I am trying to flatten an object of objects which looks something like this,
{
O75376: {
ABC: [],
XYZ: ["a", "b", "c"],
FGH: ["x", "y", "z"]
},
O75378: {
ABC: [],
XYZ: ["a", "b", "c"],
FGH: ["x", "y", "z"]
},
}
I expect it to be like 075376: ["a","b","c","x","y","z"], 075378: ["a","b","c","x","y","z"],
const flat = reduce(data, (accumulator, content, key) => {
accumulator[key] = flatMap(content, (x, y) => {
return map(x, b => {
return y + '~' + b
})
})
return accumulator;
}, {});
This works with lodash, but I couldn't figure out how this is possible with ES6.