Couldn't you do this instead, and obviate the need for filtering?

```javascript
return val == null ? memo.concat(val) : memo;
```