With ES6 you can turn Andy’s solution into as a one-liner:
const average = array => array.reduce((a, b) => a + b) / array.length;
console.log(average([1,2,3,4,5]));
With ES6 you can turn Andy’s solution into as a one-liner:
const average = array => array.reduce((a, b) => a + b) / array.length;
console.log(average([1,2,3,4,5]));