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.
I saw it. My point was that the tests passed the right arrays, and expected results were correct, so the issue wasn't with the kata itself. I agree that every
var
should be replaced withconst / let
but that's a minor issue (especially considering that the kata is in beta for 7 or so years).no, i figured everything out. i realised exactly what the issue was. see my solution to see how i fixed that
I'm not an oracle, so I don't know. Global variables? Confusion?
You can always go to Solutions tab and fork any solution, and play around with it. You can modify tests as you see fit (you will notice that adding
const
doesn't change anything). Tests pass a copy of the array, so the expected result isn't affected by your code.See above. I marked it as spoiler just in case. The "issue" seems to come from your code.
what would then?
Yeah, that wouldn't really fix the problem...
const
in JS doesn't mean what you think it does.that's why you always make randomized tests
This comment is hidden because it contains spoiler information about the solution
Poor description! nth pick stands for number of rounds and it also stands for the position of the element you have to return after completing the rounds!
This taught me quite a bit about writing tests. Very clever.
Thanks for letting me know. I just fixed that, and made the random tests be more random. Your solution should fail most of the tests now.
Your random tests are vulnerable to input modification.
I see. I changed
nth
tonthPick
and added a few examples. Does that clear up any confusion?The thing is that it's not very clear what
nth
means:nth
actually means something like above rather than things like "nth round".Don't snake drafts act the same for larger sets as they do for smaller sets? E.g.,
abc...xyz
, thenzyx...cba
, thenabc...xyz
and so on?Are the test cases not doing that?
Loading more items...