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.
This comment is hidden because it contains spoiler information about the solution
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.
hmmm ok, thanks, has sort method stability been fixed in more recents node versions tho ? Why am I having the right answer in my VScode ?
Your method uses sort, and sort is not stable. Not a kata issue unfortunately, you need to slightly alter your approach.
This comment is hidden because it contains spoiler information about the solution
thanks guys !!!
I forgot the return before the recursiv call of my function. Not sure to understand yet why it's needend though, since there is a return in the if condition that should be call at the end of the recursion. Anyway, I won't forget the return before recursiv call in the future. And thanks for the tip about the global var, it was just a patch to prevent infinite recursion.
Thanks again and have a nice day ;)
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.
This comment is hidden because it contains spoiler information about the solution
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
This comment is hidden because it contains spoiler information about the solution