Search
 
SCRIPT & CODE EXAMPLE
 

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];
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: alert confirm prompt javascript 
Javascript :: create json string c# 
Javascript :: javascript keywords 
Javascript :: react-native-cli remove 
Javascript :: string to date angular 
Javascript :: angularjs cdn 
Javascript :: htaccess for react 
Javascript :: how to check if a number is float javascript 
Javascript :: javascript full screen 
Javascript :: remove attribute javascript 
Javascript :: javascript degree to radians 
Javascript :: formdata appen array of strings 
Javascript :: nestjs cli create project 
Javascript :: slick slider infinite loop 
Javascript :: regex password validation 
Javascript :: statements and expressions in js 
Javascript :: javascript remove multiple items from array 
Javascript :: javascript copy and paste event 
Javascript :: jqery slectt div in div 
Javascript :: document load complete jquery 
Javascript :: check if an HTML element has any children 
Javascript :: angular run validation on other controls 
Javascript :: useeffect not working with react-dom-router 
Javascript :: iso string to timestamp javascript 
Javascript :: how to get greatest common divisor in javascript 
Javascript :: js get all iframes 
Javascript :: js remove json value duplicates 
Javascript :: programmatic title react 
Javascript :: cursor to pointer in react 
Javascript :: mousemove jquery 
ADD CONTENT
Topic
Content
Source link
Name
5+9 =