I would like to filter an array containing zeros (0
) whilst capturing them too:
var arr1 = [-200, -163, -26, -4, 0, 7, 76];
var evens = arr1.filter(function(x) {
if (x % 2 === 0 || x === 0) {
return x;
}
})
console.log(evens);
Why do I NOT get zero back in my evens
array? If zero is not classed as even, shouldn't my:
|| x === 0
statement catch the zero?