javascript replace big list
var obj = {
'firstname': 'John',
'lastname': 'Doe'
}
var text = "My firstname is {firstname} and my lastname is {lastname}"
alert(mutliStringReplace(obj,text))
function mutliStringReplace(object, string) {
var val = string
var entries = Object.entries(object);
entries.forEach((para)=> {
var find = '{' + para[0] + '}'
var regExp = new RegExp(find,'g')
val = val.replace(regExp, para[1])
})
return val;
}
Also in JavaScript:
- how to trigger events when the document loads in js
- reverse proxy using expressjs
- checking ascii in js
- make indexOF in js
- prevent default on enter press
- autoformat mobile number (xxx) xxx-xxx codepen
- format money javascript commas
- electron download
- node js write file
- javascript truncate array
- video js toggle play pause
- javascript get index of object with value in array
- js check if string is number
- download datepicker js
- remove last element from array javascript
- jquery wrap inner text
- regular expression for email and mobile
- js switch case greater than
- discord.js MessageEmbed
- datepicker select date programmatically bootstrap
- get all entries in object as array hjs
- javascript float to int
- javascript split array into chunks
- discord.js bad word filter