JSFiddle - React, Tailwind, and code Playground

HTML

<div id="timer">0</div>

JavaScript

function timer() {
  var s = Number(document.getElementById("timer").innerHTML);
  s++;
  document.getElementById("timer").innerHTML = s;
  if (s < 10) {
    setTimeout(timer, 1000);
  } else {
    document.write("12");
  }
}

timer();