In my code, I have a Beverages array which has another array inside of it. When I open the Beverages array in console, I see the indices. But, I want those indices to be item names which is inside an item array (i attached screenshots). How can I see the array with item names instead of indices?
TS:
forkJoin([this.items$, this.categories$]).subscribe(
([items, categories]: Array<any>) => {
const finalArray: Array<any> = [];
items.forEach((item: any) => {
let output = { item };
const foundCategory = categories.find(
(x) => x.id === item.categoryId
);
if (foundCategory) {
output = { output, ...foundCategory };
}
finalArray.push(output);
});
let grouped = [];
grouped = _.mapValues(_.groupBy(finalArray, (final) => final.name));
console.log(grouped);
}
);