Tell us what’s happening:
My code seems to work for half the solutions. I just figured that I cannot have item.last hard coded like this on my filter callback. I ran out of inspiration of how can I replace this.
An algorithm is the steps/logic needed to solve a problem. It is highly recommended to at least write out the steps in plain language or psuedo-code and validate the test cases would work with your algorithm and then convert your plain language to whatever language you want.
It is not quite that simple. Plus, last would only apply to just one of the tests. You need to think about how you would solve the tests without a computer, meaning you will need to perform certain steps (i.e. iterating, comparing various things) to arrive a the result expected for each test.
If you hardcode item.last as the comparator, the other tests will fail. The array being passed in (the one you see in the editor) is not the only array that your code should expect. Here’s another test using your same function: