Change count JavaScript function
<p>Currently, this function seems to count all the way to the higher value. I want it to simply count to the lower value of 30.</p>

<p>This is the script:</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>$(".circleStatsItemBox").each(function() {
  var value = $(this).find(".value &gt; .number").html();
  var unit = $(this).find(".value &gt; .unit").html();
  var percent = $(this).find("input").val() / 100;

  countSpeed = 2300 * percent;
  endValue = value;

  $(this).find(".count &gt; .unit").html(unit);
  $(this).find(".count &gt; .number").countTo({
    from: 0,
    to: endValue,
    speed: countSpeed,
    refreshInterval: 50
  });

  //$(this).find(".count").html(value*percent + unit);
});</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"&gt;&lt;/script&gt;
&lt;script src="https://cdn.rawgit.com/mhuggins/jquery-countTo/master/jquery.countTo.js"&gt;&lt;/script&gt;
&lt;div class="circleStatsItemBox yellow"&gt;
  &lt;div class="header"&gt;Levels of Interest&lt;/div&gt;
  &lt;span class="percent"&gt;% Increase&lt;/span&gt;
  &lt;div class="circleStat"&gt;
    &lt;input value="25" class="whiteCircle" type="text"&gt;
  &lt;/div&gt;
  &lt;div class="footer"&gt;&lt;span class="count"&gt; 
    &lt;span class="number"&gt;30&lt;/span&gt;
    &lt;span class="unit"&gt;Before&lt;/span&gt;
    &lt;/span&gt; &lt;span class="sep"&gt; / &lt;/span&gt;
    &lt;span class="value"&gt; 
&lt;span class="number"&gt;40&lt;/span&gt;
    &lt;span class="unit"&gt; During&lt;/span&gt;
    &lt;/span&gt;
  &lt;/div&gt;
&lt;/div&gt;</code></pre>
</div>
</div>
</p>