I need to check if an array has any null value. If it does return false otherwise true.
How do I turn this
checkArray(array){
for (var i = 0; i < array.length; i++) {
if (array[i] === null || array[i] === '')
return false;
}
return true;
}
into a working example with map and fat arrows?
I've tried this
checkArray(array){
array.map(function(item) {
if (item === null || item === '') {
return false;
} else {
return true;
}
return true;
})
}
But it always returns true. Why? Is it because map creates a new array?
Array#filter?it always returns undefinedbecause you return nothing fromcheckArraytruearray.mapshould return[true, false, false, true]like array in your case.