I am trying to group an array of objects like the below using JavaScript.
const array = [
{ 'red': 50 , 'green':99 , 'blue': 66},
{'blue':65, 'red': 88 },
{ 'green':9 , 'blue': 6},
{ 'red': 650 , 'green':959 , 'blue': 663},
];
and expecting the below result,
{
red: [50, 88, 650],
green: [99,9,959],
blue: [66,65, 6, 663]
}
Can we implement this using Reduce function?
Thanks in advance!.