title: Functional Programming, JavaScript, chaining, and no external library to calculate average on array of objects
body: <p>I want to use Functional Programming, JavaScript, chaining, and no external library to reduce an array of objects to the average of the grade of the element with the condition that enrolled &gt;1.
  So far I'm able to calculate the sum under the requested condition
  But how can I calculate the average? ( Note that I want to use Functional Programming, JavaScript, chaining, and no external library)</p>
  <p>Here is what I have come so far ...</p>
  <pre><code>let enrollment= [
      {enrolled: 2, grade:100},
      {enrolled: 2, grade:80},
      {enrolled: 1, grade:89}
  ]
  
  const sum = (accumulator, curr) =&gt; accumulator + curr.grade;
  
  
  enrollment
      .filter( elem =&gt; elem.enrolled &gt;1)
      .reduce(sum,0)
  </code></pre>
  <p>Now how do I chain an average function to the above block of code?
  Thanks in advance</p>