Skip to content

Instantly share code, notes, and snippets.

@webinista
Created April 1, 2014 19:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save webinista/9921600 to your computer and use it in GitHub Desktop.
Save webinista/9921600 to your computer and use it in GitHub Desktop.
A method to finding the mean (average) value from an array of numbers.
var mean = function(array){
var len, sum;
sum = array.reduce( function(a,b){
return a + b;
});
len = array.length;
return sum / len;
}
mean([2,4]); // 3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment