en.javascript.info/1-js/06-advanced-functions/07-settimeout-setinterval/3-rewrite-settimeout/solution.md
Ilya Kantor ab9ab64bd5 up
2017-03-21 14:41:49 +03:00

273 B

let i = 0;

let start = Date.now();

let timer = setInterval(count, 0);

function count() {

  for(let j = 0; j < 1000000; j++) {
    i++;
  }

  if (i == 1000000000) {
    alert("Done in " + (Date.now() - start) + 'ms');
    cancelInterval(timer);
  }

}