Open kartamyshev opened 4 years ago
function removeFalsy (arr) {
const cleanArray = [];
arr.forEach((item) => {
if (item) cleanArray.push(item)
})
return cleanArray;
}
function removeFalsy (arr) {
return arr.filter(item => item);
}
function removeFalsy (arr) {
return arr.filter(Boolean);
}
Sample array : [NaN, 0, 15, false, -22, '',undefined, 47, null] Expected result : [15, -22, 47]