It is great that you solved the challenge, but instead of posting your full working solution, it is best to stay focused on answering the original poster’s question(s) and help guide them with hints and suggestions to solve their own issues with the challenge. How to Help Someone with Their Code Using the Socratic Method
We are trying to cut back on the number of spoiler solutions found on the forum and instead focus on helping other campers with their questions and definitely not posting full working solutions.
sort requires a function, you can create the function in place as an argument, or you can use an existing function, in this case you already have an existing function available to use and should use it
Thanks for your replies. But for the sortByYear function, also no input was given to it. I just started to learn JS, don’t have too much knowledge, I don’t know how it works between sort function and the function it callbacks.
the sort method will call the function and pass the elements to it
same way it would give the input to the arrow function you wrote .sort((a,b) => …) the two parameters a and b will get a value when sort calls the function