I have to replace multiple words in a string.
my code is like this
var csku = "{len}";
var value = 5;
var finalPrice = "({con}*{len})+{wid}+{fixed_var}+{extra}+{sqft}+{len}";
console.log(finalPrice.replace(csku, value));
Using this code I got this solution
({con}*5)+{wid}+{fixed_var}+{extra}+{sqft}+{len}
but I want this
({con}*5)+{wid}+{fixed_var}+{extra}+{sqft}+5
I google it for replacing multiple words in the string using one call I find this
str.replace(/X|x/g, '');
Here /
and g
is used for multiple replace and in this format I have to add static word but in my code csku
is not fixed so how can I replace all words in one call using variable