var sum = array.reduce((a, b) => a + b, 0); //get sum of all elements in array var avg = (sum / array.length) || 0; //get average of all elements in array ;)