What is the need of embedding HTML into Javascript code?
I still don’t understand the use of embedding HTML into javascript code. I understand the use of template literals to insert HTML but still not understand why is there a need to embed HTML.
need of embedding html into jvavscript code
MY CODE:
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 […]