Let's start with an array of numbers where we need to get the maximum value.
ary = [4,7,-2,55,2,12];
It doesn't really matter how we get those numbers into the array, all that matters is that we have an array and want to get the maximum value. To get the maximum value from the array we run the following code:
max = Math.max.apply(Math,ary);
The variable max now contains the maximum value from the array called ary (if you run both these statements then max contains 55).
To get the minimum value just substitute Math.min instead of Math.max
No loops and just a single call and we have the answer.