title: Javascript counter not stopping
body: <p>for this counter I made, I used the setInterval, and when every digit is equal to zero I expect this to clear the interval, but it's not working! Can someone help me out?</p>
  <pre><code>const counterHTML = document.querySelector(&quot;#counter&quot;);
  const timeString = localStorage.getItem(&quot;Time&quot;);
  
  function timeToAdd(stringTime) {
    const timeArray = stringTime.split(&quot;:&quot;);
    const hoursInMiliseconds = timeArray[0] * 60 * 60 * 1000;
    const minutesInMiliseconds = timeArray[1] * 60 * 1000;
    const TIME_IN_MILISECONDS = hoursInMiliseconds + minutesInMiliseconds;
    return TIME_IN_MILISECONDS;
  }
  
  const actualTime = Date.now();
  const finalTimeDateObj = new Date(actualTime + timeToAdd(timeString));
  const finalTime = finalTimeDateObj.getTime();
  
  const time = (myTimerInterval) =&gt; {
    const timeNow = Date.now();
    const diference = finalTime - timeNow;
    let displayTimeArray = msToTime(diference);
    console.log(diference);
    const hours = String(displayTimeArray[0]).padStart(2, &quot;0&quot;);
    const minutes = String(displayTimeArray[1]).padStart(2, &quot;0&quot;);
    const seconds = String(displayTimeArray[2]).padStart(2, &quot;0&quot;);
    if (hours == &quot;00&quot; &amp;&amp; minutes == &quot;00&quot; &amp;&amp; seconds == &quot;00&quot;) {
      clearInterval(myTimerInterval);
    }
    counterHTML.innerText = `${hours}:${minutes}:${seconds}`;
  };
  
  function msToTime(millis) {
    let h, m, s;
    h = Math.floor(millis / 1000 / 60 / 60);
    m = Math.floor((millis / 1000 / 60 / 60 - h) * 60);
    s = Math.floor(((millis / 1000 / 60 / 60 - h) * 60 - m) * 60);
    return [h, m, s];
  }
  
  var myTimerInterval = setInterval(time, 1000);
  </code></pre>