I'm trying to filter all the values from an array that are minor than 5, the problem is that the output doesn't contain the number 0, which is contained in the original array, how can I make to filter that value to? Here's the code:
const numbers = [0,1,2,3,4,5,6,7,8,9,0];
const minor = (element) => {
if(element < 5 || element === 0){
return element;
}
}
const minorVal = numbers.filter(minor);
console.log(...minorVal)
And this is what is printed in the console:
1
2
3
4