The condition is that the element should be equal to its index in the array.
The array is [1, 1, 2, 5, 2].
[1, 1, 2, 5, 2].indexOf(1) === 0 which is false
[1, 1, 2, 5, 2].indexOf(1) === 1 which is true
[1, 1, 2, 5, 2].indexOf(2) === 2 which is true
[1, 1, 2, 5, 2].indexOf(5) === 3 which is false
[1, 1, 2, 5, 2].indexOf(2) === 4 which is false
So, the new array should contain [1, 2] but the tests expect the new array to contain [1, 2, 5]
I think the test case has an error, either it should be 3 instead of 5, or , the new array should contain [1, 2]
Challenge: Functional Programming - Implement the filter Method on a Prototype
Link to the challenge: