document.getElementById("text").innerHTML = "Hello World";
<!DOCTYPE html>
<html>
<body>
<h2>What Can JavaScript Do?</h2>
<p id="demo">JavaScript can change HTML content.</p>
<button type="button" onclick='document.getElementById("demo").innerHTML = "Hello JavaScript!"'>Click Me!</button>
</body>
</html>
// assume we have a <p> element with the id "text"
const text = document.getElementById("text")
text.innerHTML = "<h1>hey</h1>" // now it's a <h1> element
const app = document.getElementById('app');
const change_app_text = (text) => app.innerText = text;
change_app_text('Text you want');
console.log(app.innerHtml) // => <div id="app">Text you want</div>