const contentString = "MDN Web Docs";
document.body.innerHTML = contentString.link("https://developer.mozilla.org/");String.prototype.link() / notebook
String.prototype.link()
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.
<a href="https://developer.mozilla.org/">MDN Web Docs</a>const contentString = "MDN Web Docs";
const elem = document.createElement("a");
elem.href = "https://developer.mozilla.org/";
elem.innerText = contentString;
document.body.appendChild(elem);