Javascript Problems – Averaging an Array

This problem came from the Colt Steele Udemy JS Bootcamp.  He is introducing Node, and the problem is to average an array.   I had to review my array summing options.  I did it two ways — the first using the forEach() method, and the second using the reduce() method.

Once I have the sum of the array, I divide it by array.length to get the average.  I use Math.round() to round the number to the nearest integer.

 

Leave a Reply

Your email address will not be published. Required fields are marked *