I have a set of strings coming from my server-side api in the format:
"`Employee age is ${employeeAge}`"
I want to evaluate this string in a function which has reference to 'employeeAge'.
The possible ways are to use eval() :
const employeeAge = 34;
const string = eval("`Employee age is ${employeeAge}`")
expected result = "Employee age is 34"
or using [new Function]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function method
Is there any way to avoid using these methods?
Thanks