LeetCode 30 Days of JavaScript: Filter Elements from Array