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.
same lol
I think to not have it available is the point of this kata.
This is caused by outdated and confusing formatting of test cases layout. Fixed in update of the tests.
It's not a good idea to just tell the answer, or you don't learn much from it. But Chrono79 told you what the problem is exactly, and I tried showing you small steps, so you could find the problem on your own ( but you didn't seem to try them :/ ).
If you do recursion, and use
console.log
in it, you will get the answer in console, but nothing will bereturned
to you from the initial function call, so you get undefined as the final answer. CodeWars tests work with returned values, and not output from console.It doesn't mean you can't use
console.log
, but you should understand that your code doesn't stop on that line. That's why I suggest looking at recursion online, compare with your code, and see if something is missing.Well, it's your choice to believe in some fairytales, and not the truth. However, don't be surprised to see the same thing when you do another kata involving recursion :P As a popular phrase goes: "you can lead a horse to water, but you can't make it drink"
Actually, that's the entire problem... And if you don't think it is, why is your solution not accepted?
That's because you don't understand the difference between console.log and return.
Please read this: https://docs.codewars.com/training/troubleshooting/#expected-the-same
You still have
console.log
s in your solution. There shouldn't be any. And from what I see the problem is the same, your recursion is wrong.No it doesn't work. It only 'works' because you use console.log to ouput the value. Try changing the last line to
console.log(persistance(999))
and remove every singleconsole.log
inside your function. See if that changes the output.As as extra hint, get rid of the global variable (first line) and move it inside function, or you will get unpredictable results. Also, look up how recursion should be done correctly.
If this is an exact excerpt from the log, then you are probably misinterpreting it.
Please see if this paragraph helps: https://docs.codewars.com/training/troubleshooting#print-input
Language?
It's not. Why do you think it is?