-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtimer.js
More file actions
51 lines (47 loc) · 1.08 KB
/
Copy pathtimer.js
File metadata and controls
51 lines (47 loc) · 1.08 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
const seconds = document.getElementById("seconds");
const tens = document.getElementById("tens");
let num;
// console.log(seconds);
// console.log(tens);
/*
? What I have to do ?
TODO : onclick of start button, it should start from 60 to 0, means it will decrease every one second,
* Need three buttons start, stop & reset
* first make simple for 10s to decrease to 0
! Time should decrease every second,
*/
function start() {
num = prompt("Enter a Positive Number");
seconds.textContent = num;
if (num > 0) {
setInterval(decrease,1000);
}
else {
alert("Try Again!!")
}
}
function decrease() {
num = num - 1;
if (num > 0) {
if (num < 10) {
seconds.textContent = "0" + num;
}
else {
seconds.textContent = num;
}
}
else if (num == 0) {
seconds.textContent = "0" + num;
}
else {
console.log();
}
}
function stop() {
console.log("Stop is working!!");
}
function reset() {
num = 0 + "0";
seconds.textContent = num;
console.log("Reset is working!!");
}