Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class timer {
- constructor() {
- this.seconds = 0;
- this.minutes = Math.floor(this.seconds / 60);
- this.running = false;
- this.formattedSeconds = this.seconds < 10 ? `0${this.seconds}` : this.seconds;
- this.formattedMinutes = this.minutes < 10 ? `0${this.minutes}` : this.minutes;
- this.calculatedTime = `${this.formattedMinutes}:${this.formattedSeconds}`;
- }
- setTimer = () => {
- this.seconds++;
- this.time = document.getElementById('timer');
- this.running = true;
- this.time.innerHTML = this.calculatedTime;
- };
- startCount() {
- setInterval(this.setTimer, 1000)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement