I have this string
content = 'Hi John Doe,
Your appointment has been scheduled for 30-Mar-20 at 05:00 pm.
Please confirm your appointment. [link]'
confirmationTagsArray = [
{tag : '[customer_name]' : value : 'John Doe'},
{tag : '[startDate]' : value : '30-Mar-20'},
{tag : '[start_time]' : value : '05:00 pm'},
];
Here is my function to replace strings
parseBackConfirmationText() {
let str = this.content;
this.confirmationTagsArray.forEach(tag => {
if (str.includes(tag.value)) {
str.replace(tag.value, tag.tag);
}
});
return str;
}
In this function
i am replacing some strings
with another strings in a loop. But it's not replacing the strings. It returns me the same string that i provided like this
Hi John Doe,
Your appointment has been scheduled for 30-Mar-20 at 05:00 pm.
Please confirm your appointment. [link]
But it should return like this
Hi [customer_name],
Your appointment has been scheduled for [start_date] at [start_time].
Please confirm your appointment. [link]
What am i doing wrong?