var myText = document.createElement('p'); document.body.append(myText); var seconds = 0; setInterval(myFunction, 1000); function myFunction() { p.innerText = seconds.toString(); seconds++; }