Published
- 1 min read
js replace item in array at index
The solution for this is noted below
js replace item in array at index
Solution
array.splice(indexWhereToReplace, 1, replacement)
// Ex
const arr = [1, 2, 3]
arr.splice(1, 1, 'replacement')
console.log(arr) // [1, 'replacement', 3]
Try other methods by searching on the site. That is if this doesn’t work