repl.it
@Waqas909/

Working Timer

JavaScript

No description

fork
loading
main.js
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
var arr = [0,0,0,0,5,9];
var my = setInterval(function(){
  console.log(arr.join(" "));
  
  if(arr[5]===0){
    
    if(arr[4]!==0){
      arr[4]--;
      
    }else{
      
      for(var i = 3; i>=0 ;i--){
        
        if(arr[i]!==0){
          arr[i]--;
          
          
          for(var x = i+1; x<5;x++){
            if(x%2===0){
              
              arr[x]=5;
              
            }else{
              
              arr[x]=9;
              
            }
          }

          
          
          break;
        }
        
      }
      
      
      
      
    }
    
    arr[5]=9
    
    
    
    
    
    
    
    
    
  }else{
    arr[5]--;
  }
  
  var sum = arr.reduce((pv, cv) => pv+cv, 0);
    
    
  console.log(sum);  
  
  if(sum===0){
    clearInterval(my);
  }
  
  
  
},1000);
Native Browser JavaScript