whats the best way to convert an array of strings and group them together into objects if they have same substring,
const parameters = ["product_groups", "product_filters", "location_groups"];
const desiredOutput = [
{ product: ["product_groups", "product_filters"] },
{ location: ["location_groups"] }
];
Tried using the map method, however having problems grouping them and putting multiple values into the same array.
const desiredOutput = parameters.map(value => {
return {
[value]: value
};
});