Advertisement
Guest User

Untitled

a guest
Apr 4th, 2020
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. let hodiny = document.querySelector("#hodiny");
  2. let pocetVterin = 0;
  3. let pocetMinut = 0;
  4. let vteriny, minuty;
  5.  
  6. const stopky = setInterval(function() {
  7.   pocetVterin++;
  8.  
  9.   if (pocetVterin === 60) {
  10.     pocetMinut++;
  11.     pocetVterin = 0;
  12.   }
  13.  
  14.   if (pocetVterin < 10) {
  15.     vteriny = `0${pocetVterin}`;
  16.   } else {
  17.     vteriny = `${pocetVterin}`;
  18.   }
  19.  
  20.   if (pocetMinut < 10) {
  21.     minuty = `0${pocetMinut}`;
  22.   } else {
  23.     minuty = `${pocetMinut}`;
  24.   }
  25.  
  26.   hodiny.textContent = `${minuty}:${vteriny}`;
  27. }, 1000);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement