I have an array called this.data which contains a list of platforms. Each platform has its own set of section lists, where a section list consists of values like sectionName, sectionid, and sectionVal.
Now, my goal is to replace the old sectionList with a new one (stored in this.newSectionList) for a specific sectionid within a platform.
Currently, I am able to update each individual value within the sectionList using the following code:
this.data.platforms.find(a => a.platformId === platformId).sectionList.find(f => f.sectionid === this.sectionid).sectionName = this.newSectionList.sectionName;
this.data.platforms.find(a => a.platformId === platformId).sectionList.find(f => f.sectionid === this.sectionid).sectionVal = this.newSectionList.sectionVal;
However, what I really want to achieve is to completely replace the entire sectionList with this.newSectionList. What is the simplest way to do this?
The syntax below is incorrect, but how can I modify it to make it work as intended?
this.data.platforms.find(a => a.platformId === platformId).sectionList.find(f => f.sectionid === this.sectionid) = this.newSectionList;