Implement a function compact(array) that returns a new array with all falsey values removed. Falsey values in JavaScript are: false, null, 0, "", undefined, and NaN.
Example
compact([0, 1, false, 2, '', 3, null, undefined, NaN]); // [1, 2, 3] compact(['a', '', 'b', null, 'c']); // ['a', 'b', 'c']
JavaScript Function
No test results yet
Click "Run" to execute tests