Mode entretien. Minuteur de 3 min, sans indices ni autocomplétion
Filter a range
FacileFunctions3 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.
Exemples
filterRange([5, 3, 8, 1], 1, 4)Renvoie [ 3, 1 ]
filterRange([1, 2, 3, 4, 5], 2, 4)Renvoie [ 2, 3, 4 ]
Chargement de l'éditeur...
- Entrée
filterRange([ 5, 3, 8, 1 ], 1, 4)Attendu[ 3, 1 ] - Entrée
filterRange([ 1, 2, 3, 4, 5 ], 2, 4)Attendu[ 2, 3, 4 ] - Entrée
filterRange([ 10, 20 ], 1, 5)Attendu[] - Returns a new array and keeps the input
Les tests cachés se lancent à la soumission