Array.prototype.filterintermediateconst mixed = [0, 1, '', 'hello', null, true]
mixed.filter(Boolean) // β [1, 'hello', true]Pass Boolean as the callback to filter() to remove all falsy values in one step.
A common utility pattern is to remove all falsy values (false, null, undefined, 0, "", NaN) from an array by passing Boolean as the filter callback.
Challenge: Implement compact(arr) that removes all falsy values from the array.
compact([0, 1, false, 2, '', 3, null]) // β [1, 2, 3]
compact([null, undefined, NaN]) // β []