Skip to content

Commit e9e282c

Browse files
committed
Worked for some
1 parent adb3be1 commit e9e282c

3 files changed

Lines changed: 112 additions & 63 deletions

File tree

projects/timer files/change.js

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
const seconds = document.getElementById("seconds");
2+
const tens = document.getElementById("tens");
3+
let i;
4+
let num;
5+
6+
console.log(seconds);
7+
console.log(tens);
8+
9+
/*
10+
? What I have to do ?
11+
TODO : onclick of start button, it should start from 60 to 0, means it will decrease every one second,
12+
* Need three buttons start, stop & reset
13+
* first make simple for 10s to decrease to 0
14+
! Time should decrease every second,
15+
*/
16+
17+
function start() {
18+
// let i
19+
// time_in = 10
20+
// for (i=time_in; i<10; i--){
21+
// console.log(i)
22+
// // tens.textContent = i
23+
// }
24+
// console.log("Start")
25+
i = 5;
26+
num = 100;
27+
while (i<num) {
28+
tens.textContent = decrease()
29+
setInterval(decrease,1000)
30+
i += 5;
31+
}
32+
33+
// console.log("Done!!")
34+
35+
// let i
36+
// for (i=0; i<4; i++){
37+
// tens.textContent = i
38+
// }
39+
// console.log(tens)
40+
}
41+
42+
/*
43+
! function reduce() {
44+
45+
// // alert("Shown!!")
46+
} */
47+
48+
function decrease() {
49+
let i = 10;
50+
// for (i; i==0; i--) {
51+
// console.log("Done!!")
52+
// }
53+
for (num=0; num>0; num--) {
54+
i -= 1;
55+
}
56+
console.log("return i")
57+
58+
59+
// alert("done!!")
60+
// let i;
61+
// let num = 0;
62+
// for (i=10; i>num; i--) {
63+
// tens.textContent = i
64+
// // console.log("Done!!")
65+
// }
66+
// console.log(tens)
67+
}
68+
69+
function decrease_10() {
70+
i = 10;
71+
for (i; i<50; i++) {
72+
tens.textContent = i
73+
console.log(tens)
74+
// console.log("Done!!")
75+
}
76+
}
77+

projects/timer files/timer.html

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,13 @@
1313
<h1>Timer</h1>
1414
</div>
1515
<div class="timer-clock">
16-
<span id="seconds">00</span>:<span id="tens">00</span>
16+
<span id="tens">00</span>:<span id="seconds">00</span>
1717
<div class="buttons">
18-
<button class="start-btn" onclick="start()">Start</button>
19-
<!-- <button class="btn" onclick="decree()">Stop</button> -->
20-
<script src="timeout.js"></script>
21-
<button class="btn">Reset</button>
18+
<button class="btn" onclick="start()">Start</button>
19+
<button class="btn" onclick="stop()">Stop</button>
20+
<button class="btn" onclick="reset()">Reset</button>
2221
</div>
2322
<script src="timer.js"></script>
24-
<!-- <script src="timeout.js"></script> -->
2523
</div>
2624
</div>
2725
</body>

projects/timer files/timer.js

Lines changed: 31 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
const seconds = document.getElementById("seconds");
22
const tens = document.getElementById("tens");
3-
let i;
43
let num;
5-
6-
console.log(seconds);
7-
console.log(tens);
4+
// console.log(seconds);
5+
// console.log(tens);
86

97
/*
108
? What I have to do ?
@@ -15,63 +13,39 @@ TODO : onclick of start button, it should start from 60 to 0, means it will decr
1513
*/
1614

1715
function start() {
18-
// let i
19-
// time_in = 10
20-
// for (i=time_in; i<10; i--){
21-
// console.log(i)
22-
// // tens.textContent = i
23-
// }
24-
// console.log("Start")
25-
i = 5;
26-
num = 100;
27-
while (i<num) {
28-
tens.textContent = decrease()
29-
setInterval(decrease,1000)
30-
i += 5;
16+
num = prompt("Enter a Positive Number");
17+
seconds.textContent = num;
18+
if (num > 0) {
19+
setInterval(decrease,1000);
20+
}
21+
else {
22+
alert("Try Again!!")
3123
}
32-
33-
// console.log("Done!!")
34-
35-
// let i
36-
// for (i=0; i<4; i++){
37-
// tens.textContent = i
38-
// }
39-
// console.log(tens)
4024
}
4125

42-
/*
43-
! function reduce() {
44-
45-
// // alert("Shown!!")
46-
} */
47-
4826
function decrease() {
49-
let i = 10;
50-
// for (i; i==0; i--) {
51-
// console.log("Done!!")
52-
// }
53-
for (num=0; num>0; num--) {
54-
i -= 1;
55-
}
56-
console.log("return i")
57-
58-
59-
// alert("done!!")
60-
// let i;
61-
// let num = 0;
62-
// for (i=10; i>num; i--) {
63-
// tens.textContent = i
64-
// // console.log("Done!!")
65-
// }
66-
// console.log(tens)
27+
num = num - 1;
28+
if (num > 0) {
29+
if (num < 10) {
30+
seconds.textContent = "0" + num;
31+
}
32+
else {
33+
seconds.textContent = num;
34+
}
35+
}
36+
else if (num == 0) {
37+
seconds.textContent = "0" + num;
38+
}
39+
else {
40+
console.log();
41+
}
6742
}
6843

69-
function decrease_10() {
70-
i = 10;
71-
for (i; i<50; i++) {
72-
tens.textContent = i
73-
console.log(tens)
74-
// console.log("Done!!")
75-
}
44+
function stop() {
45+
console.log("Stop is working!!");
46+
}
47+
function reset() {
48+
num = 0 + "0";
49+
seconds.textContent = num;
50+
console.log("Reset is working!!");
7651
}
77-

0 commit comments

Comments
 (0)