Skip to main content

Code Golf · #22 · 2026-04-26

Remove falsy values

Difficulty 1/3 · JavaScript

How to play

Write a JavaScript function body that passes all test cases using the fewest characters. Run against examples first, then submit for the full test suite. Eagle < Birdie < Par.

Given an array, return a new array with all falsy values removed (false, 0, "", null, undefined, NaN).

Examples

f([0,1,false,2,"",3]) 1,2,3
f([null,"hi",0]) hi

Loading your progress...

Your code (function body — receives input)

function(input) { 0 chars
}

Write the shortest JavaScript function body that passes all tests · Back to hub