I am doing my first lab on callback/higher-order functions and I am very confused on what test case 11 is asking for. I don’t know what that code would look like and I am trying to reference the modules for help though I am still confused.
I am aware I shouldn’t be creating a separate sum() function, but I am unsure what I should be doing in this instance or if I am going about things the wrong way.
Of course, I am trying to wrap my head around the concept. I am referencing the module about sort()and how they use .sort((a, b) => a- b); with the rules that accompany it or rather the behaviors. I tried applying that concept here, but I still find myself unsure why this doesn’t work out.
I try to utilize the function sortByYear() and I am using a similar structure to the example in the .sort() module. The function sortByYear()returning 3 different values depending on the relationship between the two. Would this not work? It appears to show it organized in the console.
I did try putting it in-front, as an argument which should be the right way such as .sort(sortByYear(a, b));. However, theres a ReferenceError as a and b are not defined.
You’re getting closer but the syntax is to pass simply a reference of the function, the name of the function. You are writing a new arrow function and then calling sortByYear. Simply pass the name of the sortByYear function with no parentheses.