Ad
  • Default User Avatar

    Could you clarify this? I'm lost when reading it.

    instead got: '[1,2,0,1,0,1,0,3,0,1]' (notice the unsorted array)

    You don't need to sort the array. The whole kata is about moving zeros to end, not sorting them.

    my attempt is using arr.sort(function(){}), which doesn't work

    Well I truly hope it doesn't work, because arr.sort(function(){}) doesn't make sense. If you don't provide a function for sort, it's gonna sort by comparing string representations. If you provide a function for sort, it takes 2 arguments and returns a number to tell which of the 2 should stay left or right. If you provide no arguments, I don't even know what it's supposed to do, compare undefined < undefined? (I don't know :P )

    Anyway, the kata has about 17500 completions in JS, so I don't think this is an issue... If you think otherwise, open a new question / issue.