Arrays & Iterables

Compact Array (Remove Falsy)

easyJS SpecificJS / TS3 tests

Problem Statement

Implement `compact(array)` that returns a new array with all falsy values removed (`false`, `null`, `0`, `""`, `undefined`, and `NaN`).

Examples

Example 1:
compact([0, 1, false, 2, '', 3, null, undefined, NaN]); // [1, 2, 3]
JavaScript & TypeScript starter code included
Run this as a live interview

Practice solo

3 test cases. No second person needed.

Get new interview exercises

Practice problems and review drills, sent when we publish new ones. No spam.

Unsubscribe anytime. We never share your address.