Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
It appears that sorting has become stable since node v12 according to MDN. So maybe you're using js version that supports stable sorting locally.
Your method uses sort, and sort is not stable. Not a kata issue unfortunately, you need to slightly alter your approach.
Your recursion isn't going as well as you want to. Getting
undefined
means the function ended without areturn
(or with areturn
with no value, orreturn
with valueundefined
, but these two cases obviously aren't happening here). Hint: Each function can onlyreturn
for its own call.Not directly telling you so that you figure it out by thinking and learn something :)
Without seeing your code we can only guess, are you using recursion? If so, maybe you're doing it wrong. If not, are you sure your function returns the result?
After seeing your code, yes, you're doing recursion wrong. Also, don't use global vars like that, they keep their value between tests and you'll get wrong results when your function is called several times in a row.
Please see if the last bullet point of this paragraph of FAQ helps: https://github.com/codewars/codewars.com/wiki/Troubleshooting-your-solution#when-i-print-my-answer-it-looks-exactly-the-same-as-the-expected-output-yet-tests-fail