I need to replace some string values the user defines for an array of objects, but apply the rules only for some of the properties. For example if I have the following array:
[
{Name: 'Name1 Address', Fullname: 'Fullname1', Address: 'Address1'},
{Name: 'Name2', Fullname: 'Fullname2', Address: 'Address2'},
{Name: 'Name3', Fullname: 'Fullname3', Address: 'Address3'}
]
and the user wants to replace the word 'address' with 'test' but only for the 'Name' property, then the array should look like this:
[
{Name: 'Name1 test', Fullname: 'Fullname1', Address: 'Address1'},
{Name: 'Name2', Fullname: 'Fullname2', Address: 'Address2'},
{Name: 'Name3', Fullname: 'Fullname3', Address: 'Address3'}
]
Since the array can contain a lot of objects and the user can add rules for whatever property they want, how can I replace these values without having to go through each item and use string replace for a specific property?