Relative Content

Tag Archive for javascripttemplate-literals

how to use javascript to convert template literal that was stored as string back to template literal that output the variable in a function?

const a = “abc”; const tlAsText = “I dont like1 ${a}”; const converted = String.raw`${tlAsText}`; console.log(converted); // it should output “I dont like1 abc” instead of “I dont like1 ${a}” Code Sanbox To experiment: https://codesandbox.io/p/sandbox/js-rh338g?file=%2Fsrc%2Findex.mjs Tried many answers on google and chat gpt. to no avail. i.e. eval, String.raw, etc. The end goal is that […]