Find the min and max integers of an array

Codewards Question

Examples

minMax([1,2,3,4,5]) == [1,5]
minMax([2334454,5]) == [5, 2334454]
minMax([1]) == [1, 1]

Solution


function minMax(arr){
  return [Math.min.apply(null, arr), Math.max.apply(null, arr)];
}