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.
Open your browser console and type 0? true: false and then 0.1? true: false and keep changing the numbers. You will understand, it worked for me.
I've checked this very example in Python and the logic is the same, no error raised.
Function can call another function. Let's say the function has been already executed (Stringify) and the flow reached the line "Stringify(list.Next)". At this moment function has been already initiated as the flow "already works" so no error would be rised - but because we are calling same function it is called recursion ... and recursion works for python as well.
First of all study Node class really carefully. You will recognize that Node.data actually holds an integer and Node.next holds...another object Node which holds ... yes an integer and another object of type Node...and so one till Node.next holds null. I suggest to take a look closer at recursion as "conceptually" will not be enough to understand this very example. Answering your questions: When you call Stringify(list.Next) you are calling the method with object Node. Integer of that object is concatenatted to the resulted string (recursively) As i said earlier on Node.next holds another object Node or null. I would call it a tail recursion.
Are you mutating the input?
Same. I forfeited the kata and saw the top solution was the one I was attempting.
This comment is hidden because it contains spoiler information about the solution
Ternary operator.
Javascript tests are pretty bad, using
test.expect
but you must be doing something wrong to fail them. Try printing the input withconsole.log
and see why it fails. The expected answers are ok.