Filter a range
EasyFunctions3 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.
Examples
filterRange([5, 3, 8, 1], 1, 4)Returns [ 3, 1 ]
filterRange([1, 2, 3, 4, 5], 2, 4)Returns [ 2, 3, 4 ]
Loading the editor...
- Input
filterRange([ 5, 3, 8, 1 ], 1, 4)Expected[ 3, 1 ] - Input
filterRange([ 1, 2, 3, 4, 5 ], 2, 4)Expected[ 2, 3, 4 ] - Input
filterRange([ 10, 20 ], 1, 5)Expected[] - Returns a new array and keeps the input
Hidden tests run on Submit