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.

  • Default User Avatar

    Hah, good one with the '0' on the return. I padded the number with 0's instead, didn't think about that one!

  • Default User Avatar

    This comment is hidden because it contains spoiler information about the solution