11const seconds = document . getElementById ( "seconds" ) ;
22const tens = document . getElementById ( "tens" ) ;
3- let i ;
43let 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
1715function 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-
4826function 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