Finding the average value of an array in javascript using arrow functions


ES6 introduced Arrow functions along with many other functionalities which allows you to write your code in a simpler and concise way. Here is an example to find the avarage of an array using arrow functions and reduce method.

arr = [1,2,3,4,5,6,7,8,9,10]
let average = (array) => array.reduce((a, b) => a + b) / array.length;
console.log(average(arr));