I need to combine two objects that contain other objects within them, similar to the following structure:
let selections = {
123: {
abc: {name: 'abc'},
def: {name: 'def'}
},
456: {
ghi: {name: 'ghi'},
jkl: {name: 'jkl'}
}
};
let flatSelections = Object.keys(selections).reduce((r, k) => {
return selections[k];
}, {});
console.log(flatSelections);
/* expected data
flatSelections = {
abc: {name: 'abc'},
def: {name: 'def'},
ghi: {name: 'ghi'},
jkl: {name: 'jkl'}
};
*/
However, when I execute the code snippet, I only get the output of selection['456']. https://jsfiddle.net/benlesc/uw65bjo1/13/