When trying the chained method, I got an error message saying I needed to call sort and pass the sortByYear function and the test fails that step. I tested by checking to ensure that the filtered array was created correctly, which it was. I thought I understood that when chaining functions, the result of the first is passed to the second, so I’m confused about why it’s not working.
I almost think the tests should accept your answer here as well. It looks like they are too specific here.
However, if you are implementing the User Stories one at a time, it’s 2 steps:
You should filter out books written after a certain year such as 1950 from the books array and save the filtered array in a new array named filteredBooks.
You should sort the books in the filteredBooks array according to their releaseYear in ascending order. You learned in a prior lesson that the sort() method will sort the array in place. This means the filteredBooks array will be mutated.
If you chain this, then you aren’t really completing User Story 7.
The end result is the same, but the User Stories aren’t really implemented exactly as they are written.
I can see how the way the 2 user stories are written imply not chaining. The fact that it worked in VSCode is really the relevant point — the chaining logic works, it just doesn’t meet the test requirements. Thanks again