I seem to be missing something very simple here.
I am working with an array of objects that contains various information. Depending on user interaction, I want to filter out certain objects;
let arr = [
{'num': 1, 'name': 'joe'},
{'num': 2, 'name': 'jane'},
{'num': 3, 'name': 'john'},
{'num': 3, 'name': 'johnny'},
]
This is what I have attempted so far:
function filterArr(arr) {
return arr.filter(obj => {
if(obj.num && obj.num !== 1) {
return obj;
}
if(obj.num && obj.num !== 3) {
return obj;
}
})
}
After running the filterArr function, I receive the original array back instead of just {'num': 2, 'name': 'jane'},, as expected. I have added console.log statements inside both nested conditions.
I would appreciate any assistance with filtering the array based on one of two conditions being true.