1//single event i.e. alarm, time in milliseconds
2var timeout = setTimeout(function(){yourFunction()},10000);
3//repeated events, gap in milliseconds
4var interval = setInterval(function(){yourFunction()},1000);
1document.getElementById("gameStart").addEventListener("click", function(){
2 var timeleft = 15;
3
4 var downloadTimer = setInterval(function function1(){
5 document.getElementById("countdown").innerHTML = timeleft +
6 " "+"seconds remaining";
7
8 timeleft -= 1;
9 if(timeleft <= 0){
10 clearInterval(downloadTimer);
11 document.getElementById("countdown").innerHTML = "Time is up!"
12 }
13 }, 1000);
14
15 console.log(countdown);
16});