logo
Search
showing results for - "javascript average of float array"
Laney
17 Nov 2016
1Array.prototype.avg=function(fn){
2    fn =fn || function(e,i){return e};
3    return (this.map(fn).reduce(function(a,b){return parseFloat(a)+parseFloat(b)},0) / this.length ) ; 
4};
5
6[ 1 , 2 , 3].avg() ;  //-> OUT : 2
7
8[{age:25},{age:26},{age:27}].avg(function(e){return e.age}); // OUT : 26
source
similar questions
js remove first and last element from arrayjavascript find average of numberscomo acrescentar item no array jsjs string only positive float numbersfloating point in javascriptreduce average javascriptaverage of numbers in list javascriptcalculate average in javascriptjavascript float element rightaverage of an array jsgetting average of array javascriptconvert int to float in javascriptget average and sum javascriptjavascript int to floatcalculate average javascriptnumber to float jshow to calculate average of array in javascriptjavascript average of argumentsjavascript median of arrayjavascript 2 decimal float array elements
queries leading to this page
javascript average of float arrayjavascript average of float array
privacy policyterms of useinstagram
Crafted with  ♥  for everyone

sign in to continue
your answer for
you will get a confirmation link on this - you will have to click that for successful submission of your answer. we require this to keep the website free of spam, bots and unhelpful content
please ensure to add code which is syntactically corrent and executes properly
sign in to continue
ask question on maxinterview
you will get a confirmation link on this - you will have to click that for successful submission of your question. we require this to keep the website free of spam, bots and unhelpful content
please be clear, to the point and respectful
sign in to continue