I'm creating this function that returns only those objects (from an object array) whose property "a" value is not in another array of excluded numbers (which are actually strings)
I realized that I need a double iteration, tried to nest a filter, inside a filter but didn't succeed. I had to hardcode it using the OR operator like this:
const arr = [{a:"1"},{a:"2"},{a:"3"}]
const filtered = (arr)=>{
const ex = ["1","2"]
return arr.filter(e => !e.a.includes(ex[0] || ex[1]))
}
console.log(filtered(arr));
How can I loop this properly so that I don't have to use the || operator?
||operator. If you need two test in two variables, it should be!e.a.includes(ex[0]) || !e.a.includes(ex[0]). Also,||should be&&.