setText JavaScript

document.getElementById("myBtn").textContent = 'Hello World';
// OR
document.getElementById("p1").innerHTML = "New text!";
Undefined