title: Why won't my countdown timer start and stop?
body: <p>I need to make a simple countdown timer from 5 to zero, with the buttons to START and STOP the counter. The only thing that I don't know is that why won't my counter stop.</p>
  
  <p>The code is presented below:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>   function clock() {
       var myTimer = setInterval(myClock, 1000);
       var c = 5;
  
       function myClock() {
         document.getElementById("demo").innerHTML = --c;
         if (c == 0) {
           clearInterval(myTimer);
           alert("Reached zero");
         }
       }
     }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;p id="demo"&gt;5&lt;/p&gt;
  &lt;button onclick="clock()"&gt;Start counter&lt;/button&gt;
  &lt;button onclick="clearInterval(myTimer)"&gt;Stop counter&lt;/button&gt;</code></pre>
  </div>
  </div>
  </p>