I have an array of objects inside my data store in Svelte, I would like to update one property in every single object in the array, i.e. I want to update the author property inside the array in my store to the current user name, this is what I'm currently doing:
let tempArray = $myReviewDataStore;
for(var i=0; i < tempArray.length; i++){
tempArray[i].author = username;
}
myReviewDataStore.update(data =>{
return tempArray;
})
There must be a better way to do this, right?
Thanks!
This is just a shorter way to do it: