title: How to stop Javascript counter after initial result is returned
body: <p>I need to stop a counter after returning its initial result so that the result can then be innerHTL inserted as a static number off which subsequent, separate scripts rely. </p>
  
  <p>The counter works great for continual counting, but I can't stop the darned thing for the life of me.</p>
  
  <p>I've tried clearInterval, stopPropagation, modifying variables, but I'm honestly just too much of a disaster to know where to make those (or other) changes to stop and hold the initial returned value.</p>
  
  <pre><code>var counterData = {'startCounter':'1','startingDate':'02\/01\/2019','incrementPerSecond':'2','counterInterval':'3'};
  
  var canYouBelieveThisGuy = function () {
      'use strict';
  
      if ($("#stat_counter").length &gt; 0) {
  
          var currentstat =  parseFloat(counterData['startCounter'].replace(/[^\d.-]/g,''));
          var intervalSeconds = counterData['counterInterval'] * 1000; //1000;
          var increaseUnit = counterData['incrementPerSecond'];
          var initialDate = new Date(counterData["startingDate"]);
  
      setInterval(function () {
  
          var currentDate = new Date();
          var timeDiffSeconds = (currentDate - initialDate)/1000;
          var increment = timeDiffSeconds * increaseUnit;
          var currentstat2 = parseInt(currentstat + increment) * 100;
          currentstat2 = (currentstat2 / 100).toFixed(0)
          var num = (currentstat2);
          $("#stat_counter").text(num);
          }, intervalSeconds);
      };
      }
      (jQuery, this);
  </code></pre>
  
  <p>The returned value should be the number produced after the initial run, and should stop running entirely thereafter.</p>
  
  <p>Thanks for the help and for being gentle!</p>