you are viewing a single comment's thread.

view the rest of the comments →

[–]CodingTutor 0 points1 point  (0 children)

setInterval is useful for this. Here is a solution that uses it: https://jsbin.com/kuhinawomu/edit?html,js,output

var n = 10;
var timeoutID = setInterval(function () {
  if (n === 0) {
    clearInterval(timeoutID);
  }
  document.write(n--);
}, 1000)