It seems like this code should only pass the challenge if it filters out what is included in removeVals that also exists in arr. It looks like the code is saying, “filter out of arr what is not included in removeVals”. The code passes the challenge but I don’t get it. Thanks for helping me understand this.
If filter only keeps what returns true for the provided function then what’s going on with Intermediate Algorithm Scripting challenge “Diff Two Arrays”?
The answer below solves the challenge with “strictly equal” but if filter keeps what returns true in it’s function, why would the diffArray function below return 4 when to me it seems like an array of everything besides 4 should be returned since 4 isn’t “strictly equal” to any of the other numbers in the combined array.
You’re right. I’m just trying to find out why “strictly equal” in the context of the code I used to solve Diff Two Arrays doesn’t cause filter to return an array of every number instead of 4. According to @DanCouper " Filter keeps anything that returns true for the provided function".
What factors decide whether filter “filters out” or “keeps” what returns true for its provided function? @DanCouper said, " Filter keeps anything that returns true for the provided function" but you are saying that filter in the context of Diff Two Arraysfilters out what returns true for its provided function.