programming-examples/js/Array/Write a JavaScript function to filter false, null, 0 and blank values from an array..js

12 lines
320 B
JavaScript
Raw Normal View History

2019-11-15 12:59:38 +01:00
function filter_array_values(arr) {
arr = arr.filter(isEligible);
return arr;
}
function isEligible(value) {
if(value !== false || value !== null || value !== 0 || value !== "") {
return value;
}
}
console.log(filter_array_values([58, '', 'abcd', true, null, false, 0]));