Skip to content

Instantly share code, notes, and snippets.

@Dammmien
Last active October 3, 2019 09:06
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Dammmien/b5ee23f9817235c61ab4 to your computer and use it in GitHub Desktop.
Save Dammmien/b5ee23f9817235c61ab4 to your computer and use it in GitHub Desktop.
Average of an array ES6
var average = arr => arr.reduce( ( p, c ) => p + c, 0 ) / arr.length;
average( [ 1, 2, 3, 4, 5, 6, 7, 8, 9 ] );
// 5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment