Skip to content

Instantly share code, notes, and snippets.

Created July 21, 2016 19:31
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 anonymous/b19bca3754a79b53f43fa556412607ff to your computer and use it in GitHub Desktop.
Save anonymous/b19bca3754a79b53f43fa556412607ff to your computer and use it in GitHub Desktop.
function maxMinAvg(arr) {
var max = arr[0];
var min = arr[0];
var avg = 0;
var arrnew = [max, min, avg];
for(var a=0; a<arr.length; a++){
if(arr[a]>max){
max = arr[a];
}
if(arr[a]<min){
min = arr[a];
}
avg = arr[a]+avg;
avg = avg/arr.length;
}
return arrnew;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment