I want to array an object from this array by array parent name.
I am getting data like the above image.
I tried this and got this result:
const items = {};
this.basketData.Categories.forEach(arr => {
arr.forEach(obj => {
const { ParentCategoryName, ChildItems } = obj;
if (items[ParentCategoryName]) {
items[ParentCategoryName].push(ChildItems[0]);
} else {
items[ParentCategoryName] = [ChildItems[0]];
}
});
});
And get this result from the above codes:
Please help…