Practice Real Company Assessment Patterns • Latest 2025–2026 Mock Tests

Programming Exercises

Create a function that removes all falsy values (false, 0, "", null, undefined, NaN) from an array.

Easy

Problem Statement

Create a function that removes all falsy values (false, 0, "", null, undefined, NaN) from an array.

Sample Input

[0, 1, false, 2, "", 3, null, undefined, NaN]

Sample Output

[ 1, 2, 3 ]

Limits

Time: 2s · Memory: 256 MB

Code Editor
00:00
// Remove all falsy values from an array function removeFalsy(arr) { return ; } console.log();
Log in or sign up to run or submit your code.Log inSign up
Input
[0, 1, false, 2, "", 3, null, undefined, NaN]
Expected Output
[ 1, 2, 3 ]