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.
Create a copy of the given linked list, iterate over the copy, and modify each of its nodes according to the given function. Return the modified copy of the list. The original list must remain unmodified.
P.S. You can't create a copy of a linked list by simply creating a new variable.
Example in JavaScript:
const newHead = head; // This won't work! It doesn't create a copy. It creates a reference to the same list.
You must build a new list, node by node.
I still think it is a kata issue, the original list should not be mutated should be a requirement then :/
Same issue here. Can you explain better why list shouldn't be mutated in this test when function is x=>x+1 (which obiously mutates the result)?
The function is ok, that test it's not testing the output value, it's testing the input before and after your function is called.
Not a kata issue, you've mutated the list