1//Returns number with highest value.
2var x = Math.max(-5, 12, 27);
3console.log(x)//27
1//get min/max value of arrays
2function getArrayMax(array){
3 return Math.max.apply(null, array);
4}
5function getArrayMin(array){
6 return Math.min.apply(null, array);
7}
8var ages=[11, 54, 32, 92];
9var maxAge=getArrayMax(ages); //92
10var minAge=getArrayMin(ages); //11
1Math.max() function returns the largest of the zero or more numbers given as input parameters.
2Math.max(1,10,100); // return 100
1x = findMax(1, 123, 500, 115, 44, 88);
2
3function findMax() {
4 var i;
5 var max = -Infinity;
6 for (i = 0; i < arguments.length; i++) {
7 if (arguments[i] > max) {
8 max = arguments[i];
9 }
10 }
11 return max;
12}
13