title: Change Calculator Function Not Working (Javascript)
body: <p>I am making a change calculator for class and I am running into a snag. After some time messing around with the coding, I know it works until the if statements in the <code>makeChange</code> function. I am not sure how to change the functions to get them to work and show something in the HTML boxes.</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>/* global math */
  
  var $ = function(id) {
    return document.getElementById(id);
  };
  
  var makeChange = function() {
    var cents = parseInt($("cents").value);
    if (cents &lt;= 99 &amp;&amp; cents &gt;= 25) {
      var quarters = math.floor(cents / 25);
      ($("quarters").value).innerHTML = quarters;
    }
    if (cents &lt;= 24 &amp;&amp; cents &gt;= 10) {
      var dimes = math.floor(cents / 10);
      ($("dimes").value).innerHTML = dimes;
    }
    if (cents &lt;= 9 &amp;&amp; cents &gt;= 5) {
      var nickles = math.floor(cents / 5);
      ($("nickles").value).innerHTML = nickles;
    }
    if (cents &lt;= 4 &amp;&amp; cents &gt;= 1) {
      var pennies = math.floor(cents / 1);
      ($("pennies").value).innerHTML = pennies;
    }
  };
  var processEntry = function() {
    var cents = parseInt($("cents").value);
    if (cents &gt;= 0 &amp;&amp; cents &lt;= 99) {
      $("cents").value = makeChange(cents);
    }
    if (isNaN(cents)) {
      alert("Please enter a number between 0 and 99.");
    }
  
  };
  
  window.onload = function() {
    $("calculate").onclick = processEntry;
  };</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  
  &lt;head&gt;
    &lt;meta charset="utf-8"&gt;
    &lt;title&gt;Make Change&lt;/title&gt;
    &lt;link rel="stylesheet" href="styles.css"&gt;
    &lt;script src="make_change.js"&gt;&lt;/script&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
    &lt;main&gt;
      &lt;h1&gt;x x's Change Calculator&lt;/h1&gt;
  
      &lt;label&gt;Enter amount of change due (0-99):&lt;/label&gt;
      &lt;input type="text" id="cents" /&gt;
      &lt;input type="button" value="Calculate" name="calculate" id="calculate" /&gt;&lt;br&gt;&lt;br&gt;
  
      &lt;label&gt;Quarters:&lt;/label&gt;
      &lt;input type="text" id="quarters" disabled&gt;&lt;br&gt;
  
      &lt;label&gt;Dimes:&lt;/label&gt;
      &lt;input type="text" id="dimes" disabled&gt;&lt;br&gt;
  
      &lt;label&gt;Nickels:&lt;/label&gt;
      &lt;input type="text" id="nickels" disabled&gt;&lt;br&gt;
  
      &lt;label&gt;Pennies:&lt;/label&gt;
      &lt;input type="text" id="pennies" disabled&gt;&lt;br&gt;
  
    &lt;/main&gt;
  &lt;/body&gt;
  
  &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>