Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

min max and average finder in js array

function maxMinAvg(arr) {
  var max = arr[0];
  var min = arr[0];
  var sum = 0 ;
 arr.forEach(function(value){
     if(value > max)
       max = value;
     if(value < min)
       min = value;
     sum +=value;
 })
 var avg = sum/arr.length;
return [max,min,avg];
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #min #max #average #finder #js #array
ADD COMMENT
Topic
Name
5+9 =