forked from paulphilip/pythoncode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtimer.js
More file actions
29 lines (28 loc) · 656 Bytes
/
timer.js
File metadata and controls
29 lines (28 loc) · 656 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
var buttons=document.getElementById('btn');
var counter=0;
var interval;
var t=0;
buttons.addEventListener('click',function(){
var inputt=document.getElementById('input-type');
var x=inputt.value;
var showNumbers=document.getElementById('small');
// showNumbers.innerText=x;
interval=setInterval(print,1000,showNumbers,x);
});
function print(showNumbers,x){
t++;
showNumbers.innerText=t;
if(t>=x){
clearInterval(interval);
return;
}
// for(let y=0;y<x;){
// if(y>x){
// clearInterval(interval);
// return;
// }
// y++;
// console.log(y);
// showNumbers.innerText=y;
// }
}