I have the following code is there anyway to use a variable in it? It is returning the variable as a string and not returning the value of the variable.
replace = replace.replace(new RegExp(amerMatch[i] + "\.", "i"), `<span class="highlight">library[amerMatch[i]]</span>` + ".")
result:
Can you toss this in the library[amerMatch[i]] for me?
2
Answers
use
${ }
maybe you can use
eval(replace)
to get the result of library[amerMatch[i]]