Could not find a working solution but I am creating a new object from some data inside a loop but the date contains double values so it should prevent this from adding to the new object. The name property should contain unique values only.
public listOfItems: {[key: number]: {name: string; inStock: boolean}} = {};
dataAndStuff.forEach((item, i) => {
this.listOfItems[i] = {
name: item.itemName,
instock: false,
};
});
// output
[
{name: 'audi', inStock: true}
{name: 'bmw', inStock: true}
{name: 'audi', inStock: true}
{name: 'kia', inStock: true}
]