title: summation of score - mean doesnt work
body: <p>I tried making mean deviation calculator using javascript but when I try to output the summation of <code>|x-x̅|</code>, It always returns 0;</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>var frequencies = []
  var output = document.getElementById("text")
  
  function add() {
    var score = document.getElementById("lol").value
    frequencies.push(score)
  
  }
  
  function show() {
    //Calculate the mean
    var total = 0
    var mean = 0
    var scoreMinusMean = []
    var summation = 0
    for (i = 0; i &lt; frequencies.length; i++) {
      total += parseInt(frequencies[i])
    }
    mean = total / frequencies.length
    //Gets the score - mean
    for (j = 0; j &lt; frequencies.length; j++) {
      scoreMinusMean.push(Math.abs(frequencies[j] - mean))
    }
    for (k = 0; k &lt; scoreMinusMean; k++) {
      summation += scoreMinusMean[k]
    }
    output.innerHTML = scoreMinusMean
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;input id="lol"&gt;
  &lt;button onclick="add()"&gt;Add&lt;/button&gt;
  &lt;button onclick="show()"&gt;Show&lt;/button&gt;
  
  Output: &lt;span id="text"&gt;&lt;/span&gt;</code></pre>
  </div>
  </div>
  </p>