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.
why do you feel its inefficient?
Nice :)
Thanks, i've completed it now. Learnt something new today!
What you can do is use .slice() on the array when assinging it at the begining. I think this should make a proper copy of the object.
You're changing the original arrays, and that's messing with the tests.
If you print out a1 and a2 at the end, you'll see that they've changed.
If you really want to change the arrays, you'll have to deepcopy them. This is because an array in JavaScript is also an object and variables only hold a reference to an object, not the object itself. Thus both variables have a reference to the same object - if you change one, the other will change too.
This comment is hidden because it contains spoiler information about the solution
Yeah, I'm not sure then.
It may be because you might be changing the original array.
It works fine in JS for me.
Could you post your code here and mark it as a spoiler so I could take a look?
This comment is hidden because it contains spoiler information about the solution
JS is fine. You can see that there are 806 JS completions.
It the description, it says If a1 and/or a2 are empty return -1. Only one array needs to be empty.
JS
which language?
Some random tests have the expected result being -1 when both arrays are clearly not empty. Can someone else confirm this? I'm pretty sure my code is correct.