I'm using forEach in a vuejs watcher to modify my array of objects. Goal is to have the new value (end_time) in each object at the end. allChapters already contains everything I want but I can't seem to get it written back to the original object.
watch: {
episode (episode) {
episode.chapters = episode.chapters.forEach((chapter, index, allChapters) => {
let endTime = ''
if (allChapters[(index + 1)]) {
endTime = allChapters[(index + 1)].start_time
} else {
endTime = '99:99:99'
}
console.log(index + ': ' + chapter.start_time + ' / ' + endTime)
allChapters[index] = {
'start_time': chapter.start_time,
'title': chapter.title,
'end_time': endTime
}
})
}
},