replace a document in an array if you know its index code example
Example: js replace item in array at index
array.splice(indexWhereToReplace, 1, replacement)
// Ex
const arr = [1, 2, 3]
arr.splice(1, 1, 'replacement')
console.log(arr) // [1, 'replacement', 3]