Asynchronous task

by acasquete

HTML

<button id="butStart">Start</button>
<button id="butClick">Click Me!</button>

JavaScript

document.getElementById("butStart").onclick = doInterval;
document.getElementById("butClick").onclick = doClick;

function doInterval () {
   setInterval(doSomething, 2000); 
}

function doSomething() {
    var a = 1000000000;
    while (a--);
    console.log("Something done!");
}

function doClick() {
    console.log("Click!");
}