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.
😂just because
Maybe I should add an extra test for that :)
Seems it has something to do with the
delete that[j];
line. If I comment it out, the length change works fine. I'm not entirely sure why you're deleting those items, anyway; if the length changes to omit those items, then they'll be deleted. And if the length doesn't change to omit those items, there are effectivelyundefined
s in place of those items, which isn't a desired effect of splice anyway, right?Yeah-- But you can post spoilers. So you can post your full code, mark is as a spoiler (thereby hiding it from yourself), but we can still see it, and you can still see our replies to it. I'll have a look a tthe gist anyway...
Very curious. Your code looks like it should work. It's hanging on this line in
reindex()
:It doesn't time out if you put a
return
right before that line, and it does time out if you put areturn
right after that line. Just before that line, the contents ofthat
is[1,4,undefined,undefined]
,that.length
is 4, andnewLength
is 2.So I don't see a reason that line should fail. It could be that the particular implementation of JavaScript that Codewars is using has a bug which only happens when both the
delete
statement and array.length
truncation are used. It works fine for me in the browser (Chrome).This comment is hidden because it contains spoiler information about the solution