I need to mutate a strings quotes from double/single quotes to backticks, after it has already been created, so that I can add variables into the string.
I tried using replace(), but it seems as though JS does not evaluate the variable again after the replace method runs.
I am trying to understand if it is something that is possible to do, or variables can only be added to a string in JavaScript manually, and not dynamically?
Here is my code:
const variable = 9;
let strWithVar = "${variable}".replace(/"+/g, "`");
console.log(strWithVar);
The current return value is:
${abc}