-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
38 lines (35 loc) · 979 Bytes
/
Copy pathapp.js
File metadata and controls
38 lines (35 loc) · 979 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
30
31
32
33
34
35
36
37
38
let min_html = document.getElementById('min');
let sec_html = document.getElementById('seconds');
let milli_html = document.getElementById('milliseconds');
let watchInterval ;
let minutes = 0;
let seconds = 0;
let milliseconds = 0;
function start(){
watchInterval = setInterval(function(){
milliseconds++
if(milliseconds >= 99){
seconds++
milliseconds = 0
}
if(seconds >= 59){
minutes++
seconds = 0
}
milli_html.innerText = milliseconds
sec_html.innerText = seconds < 10 ? '0' + seconds : seconds
min_html.innerText = minutes < 10 ? '0' + minutes : minutes
}, 10);
}
function stop(){
clearInterval(watchInterval)
}
function reset(){
clearInterval(watchInterval)
minutes = 0 ;
seconds = 0 ;
milliseconds = 0 ;
milli_html.innerText = milliseconds
sec_html.innerText = seconds
min_html.innerText = minutes
}