I have an array object like this
[
{category_name: "category_1", id: [1]},
{category_name: "category_2", id: [1]},
{category_name: "category_1", id: [2]},
{category_name: "category_3", id: [2]},
{category_name: "category_2", id: [3]},
{category_name: "category_2", id: [4]},
{category_name: "category_3", id: [4]},
{category_name: "category_2", id: [5]},
{category_name: "category_3", id: [5]},
{category_name: "category_3", id: [6]},
],
how can i convert it to an array like this
[
{category_name: "category_1", id: [1,2]},
{category_name: "category_2", id: [1,3,4,5]},
{category_name: "category_3", id: [2,4,5,6]},
]
exactly the category names will be reduced to odd numbers and their ids will be collected in an array