var arr = [5, 3, 10, 8, 21, 4, 2], min = arr.sort(), max = min.reverse(); alert('min: ' + min[0] + ', max: ' + max[0]);