title: How do I get the decimal length to 6 decimal places in javascript?
body: <p>I am writing code to round to six decimal places after some arithmetic. I am looping through the contents of an array and finding out the contents of the array. Then I divide it by the array length. I found the function toFixed. I am setting toFixed(6). So for example. arraycontents/array.length.toFixed(6) Should get six places after the decimal. I am only getting 1?</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>array = [1, 1, 0, -1, -1];
  
  var positive_count = 0;
  var negative_count = 0;
  var zero_count = 0;
  
  function plusMinus(array) {
  
    for(var i = 0; i &lt; array.length; i++) {
  
  
      if(array[i] &gt; 0) {
  
        positive_count++;
        //console.log("Positive Count " + positive_count);
      
        
      } else if (array[i] &lt; 0) {
  
        negative_count++;
        //console.log("Negative Count " + negative_count);
      } else if (array[i] == 0) {
  
        zero_count++;
       // console.log("Zero count " + zero_count);
      }
        
    }
  
    var calculatePos = positive_count/array.length.toFixed(6);
    calculatePos.toFixed(6);
    console.log(calculatePos);
    
    var calculateNeg = negative_count/array.length.toFixed(6);
    console.log(calculateNeg);
    
    var calculateZero = zero_count/array.length.toFixed(6);
    console.log(calculateZero);
  
    
  }
  
  plusMinus(array);</code></pre>
  </div>
  </div>
  </p>