Created
July 21, 2016 19:31
-
-
Save anonymous/b19bca3754a79b53f43fa556412607ff to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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