I need to search for a keyword over an array of objects and replace all instances of it.
For example, I have the following array:
const test = [
{
marketType: 90,
displayName: "FT Total Match {scoreType} Over / Under 0.75 Remove",
},
{
marketType: 90,
displayName: "FT Total Match {scoreType} Over / Under 1 Remove",
},
]
I want to find and replace all {scoreType} with goals in the array above.
So far I have tried converting the array to a string, running a replace on it, and converting it back to an array. But when I console log the result, I still see {scoreType} and no errors.
console.log('result: ', JSON.parse(JSON.stringify(test).replace('{scoreType}', 'goals')));
Can anyone tell me what I've done wrong?