| 
 Упростить код
 Есть такой кусок кода от видео-плеера: 
video.addEventListener('timeupdate', function() {
    if (!controls.progressBar.getAttribute('max')) controls.progressBar.setAttribute('max', video.duration);
    controls.progressBar.value = this.currentTime;
    controls.currentTime.innerHTML = (this.currentTime.toFixed(1) < 10) ? '0' + this.currentTime.toFixed(2).replace('.', ':') : this.currentTime.toFixed(2).replace('.', ':');
});
  
controls.currentTime — это выделенный на скрине блок.
 
Изначально в HTML написано 00:00, но когда видео проигрывается — время обновляется. Метод currentTime у видео вставляет число с плавающей точкой, я ее заменяю на ":". И нужно, если кол-во секунд меньше 10, то добавлялся еще 0. Я сделал так, это работает, но мне кажется что можно как то упростить этот код?
 
controls.currentTime.innerHTML = (this.currentTime.toFixed(1) < 10) ? '0' + this.currentTime.toFixed(2).replace('.', ':') : this.currentTime.toFixed(2).replace('.', ':');
 |