I have a task to remove false, null, 0, "", undefined, and NaN elements from an given array. I worked on a solution which removes all except null. Anyone can expla
You can use Array.prototype.filter for truthy value check - see demo below:
Array.prototype.filter
function bouncer(array) { return array.filter(function(e) { return e; }); } console.log(bouncer([1,"", null, NaN, 2, undefined,4,5,6]));