1var obj = {
2 'firstname': 'John',
3 'lastname': 'Doe'
4}
5
6var text = "My firstname is {firstname} and my lastname is {lastname}"
7
8alert(mutliStringReplace(obj,text))
9
10function mutliStringReplace(object, string) {
11 var val = string
12 var entries = Object.entries(object);
13 entries.forEach((para)=> {
14 var find = '{' + para[0] + '}'
15 var regExp = new RegExp(find,'g')
16 val = val.replace(regExp, para[1])
17 })
18 return val;
19}