Modo entrevista. Cronômetro de 3 min, sem dicas e sem autocompletar
Filter a range
FácilFunctions3 min
Write a function filterRange(numbers, a, b) that returns a new array of the numbers from numbers that are at least a and at most b.
Keep the order of the numbers. Do not change the input array.
Exemplos
filterRange([5, 3, 8, 1], 1, 4)Retorna [ 3, 1 ]
filterRange([1, 2, 3, 4, 5], 2, 4)Retorna [ 2, 3, 4 ]
Carregando o editor...
- Entrada
filterRange([ 5, 3, 8, 1 ], 1, 4)Esperado[ 3, 1 ] - Entrada
filterRange([ 1, 2, 3, 4, 5 ], 2, 4)Esperado[ 2, 3, 4 ] - Entrada
filterRange([ 10, 20 ], 1, 5)Esperado[] - Returns a new array and keeps the input
Os testes ocultos rodam no envio