Modo entrevista. Cronômetro de 5 min, sem dicas e sem autocompletar
Min and max
FácilArrays5 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.
Exemplos
minMax([3, -2, 8, 0])Retorna { min: -2, max: 8 }
minMax([7])Retorna { min: 7, max: 7 }
Carregando o editor...
- Entrada
minMax([ 3, -2, 8, 0 ])Esperado{ min: -2, max: 8 } - Entrada
minMax([ 7 ])Esperado{ min: 7, max: 7 }
Os testes ocultos rodam no envio