2 * Replace the first occurrence of an item from an array by another item. Return a copy of the updated array
4 export default <T>(arr: T[], item: T, replacement: T) => {
5 const i = arr.indexOf(item);
9 const result = arr.slice();
10 result.splice(i, 1, replacement);