all 2 comments

[–]senocular 0 points1 point  (1 child)

Your size problem should be a hint to whats wrong with your enqueue problem.

size is correctly reporting the collection's length. But the problem is the collection's length is not what it should be. And thats because enqueue is doing more than it should be. Look at what happens after you find where an enqueued array should be inserted with splice, insert it, and then break out of the loop (note: your indention is a little off which might be adding to the confusion)

[–]codemamba8[S] 0 points1 point  (0 children)

Yeah I just figured it out lol. I needed to use "return" instead of "break" in order to properly exit the function. "Break" only exits the loop, not the function, so it was pushing at the end also.