Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. class timer {
  3.     constructor() {
  4.         this.seconds = 0;
  5.         this.minutes = Math.floor(this.seconds / 60);
  6.         this.running = false;
  7.         this.formattedSeconds = this.seconds < 10 ? `0${this.seconds}` : this.seconds;
  8.         this.formattedMinutes = this.minutes < 10 ? `0${this.minutes}` : this.minutes;
  9.         this.calculatedTime = `${this.formattedMinutes}:${this.formattedSeconds}`;
  10.     }
  11.  
  12.     setTimer = () => {
  13.         this.seconds++;
  14.         this.time = document.getElementById('timer');
  15.         this.running = true;
  16.         this.time.innerHTML = this.calculatedTime;
  17.     };
  18.  
  19.     startCount() {
  20.         setInterval(this.setTimer, 1000)
  21.     }
  22.  
  23.  
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement