Min and max
EasyArrays5 min
Write a function minMax(numbers) that returns an object { min, max } with the smallest and the largest number of an array. The array is not empty. Do not use Math.min or Math.max.
Examples
minMax([3, -2, 8, 0])Returns { min: -2, max: 8 }
minMax([7])Returns { min: 7, max: 7 }
Loading the editor...
- Input
minMax([ 3, -2, 8, 0 ])Expected{ min: -2, max: 8 } - Input
minMax([ 7 ])Expected{ min: 7, max: 7 }
Hidden tests run on Submit