I'm dealing with an array of objects that looks like this
let array = [
{
sector: "adad"
},
{
sector: "adadasdsd"
},
{
sector: "sdsdsd"
},
{
origin: "sdfsf"
},
{
destination: "dfsfsdf"
}
];
My goal is to transform it into this format:
let array = [
{ sector: ["adad", "adadasdsd", "sdsdsd"] },
{ origin: ["sdfsf"] },
{ destination: ["dfsfsdf"] }
];
I believe using the reduce method is the way to go here, but I'm struggling with the implementation. Any guidance on how to achieve this transformation?