Mapping and filtering are quite similar insofar as both imply going through all the elements in an array and applying a callback to each to produce output. Let's first work out the mapping logic, which will have several points to solve, and then we should see that filtering has become almost trivially easy, requiring just small changes.
For mapping, given how we are developing recursive functions, we need a base case. Fortunately, that's easy: mapping an empty array just produces a new empty array. Mapping a nonempty array can be done by first applying the mapping function to the first element of the array, then recursively mapping the rest of the array, and finally producing a single array accumulating both results. ...