How to search a value and replace in array?
Map the array to a new array, and call .replace
(or, more appropriately, .replaceAll
) on every item.
const input = ['asd dsa', 'asd', 'dsa asd', 'abc'];
const result = input.map(
str => str.replaceAll('asd', 'abc')
);
console.log(result);