falsyBouncer
Remove all falsy values from an array. Falsy values in JavaScript are false, null, 0, '', undefined, and NaN.
Examples
falsyBouncer([7, 'ate', '', false, 9]) → [7, 'ate', 9]
Starter code
function falsyBouncer(arr) {
}
Complexity of the optimal solution
Time O(n), space O(n). The `filter` method iterates through all n elements of the array. It creates a new array to store the results, which can be up to size n in the worst case (if no elements are falsy).