2👍
✅
It can be achieved this way:
const obj = {};
array.forEach((item) => {
Object.entries(item).forEach(([key, value]) => {
if(key in obj) {
obj[key].push(value);
} else {
obj[key] = [value];
}
});
});
console.log(obj);
Source:stackexchange.com