Variável JavaScript na String HTML

let div = document.createElement("div");
div.classList.add("yourClass");
div.setAttribute("onclick", "yourFunction()");
div.setAttribute("onmouseover", "hoverOn()")
div.style.background = "yourColor";
let divInDiv = document.createElement("div");
divInDiv.classList.add("yourClass");
div.appendChild(divInDiv);
Zwazel