I have an object which contains UTF-8 characters as strings - I figured I could make another object with the list of characters and how I'd like to replace them?
The Data Object
var data = [
{"my_string":"ABC & I","value":13,"key":8},
{"my_string":"A “B” C","value":12,"key":9}
];
The Replacement Object
var str_to_change = [
{value: "&", replace: "&"},
{value: "“", replace: ""},
{value: "”", replace: ""}
];
I'd like to write a function where anytime a str_to_change.value
is seen inside data.my_string
, replace it with str_to_change.replace
Is this the best way to go about changing various character strings, and how would I execute this? I found this: Iterate through object literal and replace strings but it's a little more complex since I'm not just replacing with a singular string.