Turnarary operators and .sort

const sortedList = inventor.sort((inventor) a > b  ? 1; -1);

This is being used to sort a list via year. What i need to know is what happens when two years are the same on my list. How could i add a default or third item to my turnarary function.

would i use the || double pipe(or) then put the last outcome or the double ?? Anyone care to show me the proper formatting for this example.

you can use nested ternary operator (you substitute one of the values with an other ternary operator)

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.