Following code is a working logic that receives entries which is an object from an API response. What I am currently doing is to assign entry.listedContent to entryOne.id & entryOne.name properties
I heard that this way, I will be modifying the original items from the array (this.entries). I was told that I should be assigning my final value to a different array, so the original is not touched/modified.
Anyone can advise what is the best practice to handle such cases?
itemList() {
return this.entries.map((entry) => {
if (this.type === "selected") {
entry.listedContent = entry["entryOne.id"] + " - " + entry["entryOne.name"]
}
return entry;
});
},