Sorry for the noob question .....
I have 2 object with strings in an array .....
const collection = [
{name: 'strA', value: 'Hello World'},
{name: 'strB', value: 'World'},
]
I only want to replace the string value that has the entire phrase 'World'
Simply doing ....
collection.map((item) => {
item.value.replace('World', 'Earth')
});
will undesirably change my array to ...
const collection = [
{name: 'strA', value: 'Hello Earth'},
{name: 'strB', value: 'Earth'},
]
when in fact, what I wanted was ....
const collection = [
{name: 'strA', value: 'Hello World'},
{name: 'strB', value: 'Earth'},
]
Any ideas?
Thanks!