title: How to dynamically calculate the array of object values in Javascript?
body: <p>I have input format as below,</p>
  <pre><code>var boxplotInput = [{Day: &quot;01-07-2021&quot;, &quot;Thomas&quot;: 95, &quot;Diana&quot;: 94, &quot;Claura&quot;: 93, &quot;Chandler&quot;: 93},
      {Day: &quot;02-07-2021&quot;, &quot;Thomas&quot;: 95, &quot;Diana&quot;: 94, &quot;Claura&quot;: 94, &quot;Chandler&quot;: 94},        
      ...
      ...
      {Day: &quot;31-07-2021&quot;, &quot;Thomas&quot;: 92, &quot;Diana&quot;: 94, &quot;Claura&quot;: 93, &quot;Chandler&quot;: 91}];
  </code></pre>
  <p>I am quite new to javascript objects handling. I have written the code as below to calculate Q1, Q3, and median and it is working fine mathematically the way I am expecting.</p>
  <pre><code>//Getting the list of students (excluding date)
  var keys;
  for(var i = 0; i &lt;boxplotInput.length; i++ ){
    keys = Object.keys(boxplotInput[i]).slice(1);      
  }
  
  ////Here, I am hard-coding keys[0]. and getting &quot;Thomas&quot; data only. I am not getting how to avoid for one students only and achieve it for all students.
  var studentDataSample = [];
  for(var i = 0; i &lt;boxplotInput.length; i++ ){  
    student1 = boxplotInput[i][keys[0]];
    studentDataSample.push(student1);
  }
  
  studentDataSample.sort(function(a, b) {return a - b;});
  
  var length = studentDataSample.length;//31
  var midIndex = middleIndex(studentDataSample, 0, length);//16
  var medianValue = studentDataSample[midIndex];
  
  var Q1 = studentDataSample[middleIndex(studentDataSample, 0, midIndex)];
  var Q3 = studentDataSample[middleIndex(studentDataSample, midIndex + 1, length)];
  
  console.log(Q1+&quot;, &quot;+medianValue+&quot;, &quot;+Q3);// here, the values are fine.
  
  function middleIndex(data, initial, length){
    var n = length - initial + 1;
      n = parseInt((n + 1) / 2);
      return parseInt(n + initial);
  }
  </code></pre>
  <p>Something, I understand that it could be achievable through the loop again.. but, not getting how to achieve it for all the students. Kindly, provide the suggestion or idea on this.</p>
  <p>Thanks in advance.</p>