js replace element in array by 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]
array.splice(indexWhereToReplace, 1, replacement)
// Ex
const arr = [1, 2, 3]
arr.splice(1, 1, 'replacement')
console.log(arr) // [1, 'replacement', 3]