Looking to transform strings based on specific rules?
"Hello {{firstName}}, this is {{senderName}}."
Consider the following rules:
rules = {
firstName: "Alex",
senderName: "Tracy"
}
The expected output would be:
"Hello Alex, this is Tracy."
If you need a versatile function to automate this process for any string and set of rules, look no further.
Take for instance:
let array = "Hello {{firstName}} {{lastName}}, this is {{senderName}}."
rules = {
firstName: "Alex",
lastName: "James",
senderName: "Tracy"
}
expectedResult = "Hello Alex James, this is Tracy."
Your assistance in achieving this task would be highly valued.