What i need is just replace a specific value in my array, not it all. Exemple:
let ARRAY = ['asd dsa', 'asd', 'dsa asd', 'abc']
I need to remove the words "asd" and replace to "abc" like:
['abc dsa','abc','dsa abc','abc']
My attempt:
ARRAY.replace(/asd/g, 'abc');
but not even in array this works. there is some way to make it?
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);