title: JavaScript - Calculating values based on an array
body: <p>I have an array, pictured below, which contains a number of values which I would like to do some calculations on a then push to a separate array.</p>
  
  <p>This is is an example of the array and data I an working with:</p>
  
  <p><a href="https://i.stack.imgur.com/iIXdU.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/iIXdU.png" alt="Original Array"></a></p>
  
  <p>I would like to push this data into an array called formatted, This array must contain the following information:</p>
  
  <p><strong>name</strong> - taken from the name form the original array</p>
  
  <p><strong>min</strong> - the lowest value from the original array</p>
  
  <p><strong>max</strong> - the largest value from the original array</p>
  
  <p><strong>Q1</strong> - this is the lower quartile which is calculated from the original array by adding the p30 and p40 values and dividing by 2</p>
  
  <p><strong>Q4</strong> - this is is the upper quartile value which is calculated by adding the p70 and p80 values together and dividing by 2</p>
  
  <p><strong>median</strong> - this is calculated by adding the p50 and p60 values together and dividing by 2 </p>
  
  <p>This is an example of how I tried to solve this but as seen below I had a error on every value:</p>
  
  <pre><code> var formated = [];
          for(var i=0; i &lt; final.length; i++) {    
              formated.push({
                  name: final[i].name,
                  min: final[i][0],
                  max: final[i].length -1,
                  Q1: (final[1] + final[2] / 2),
                  Q2: (final[5] + final[6] / 2),
                  meidan: (final[3] + final[4] / 2)
              });
          }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/lyRom.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/lyRom.png" alt="enter image description here"></a></p>