Ad
  • Custom User Avatar

    everything is correct with logic

    Nothing is correct with this logic. You're providing only partial implementation of sort function. It may work in later node versions, but you can't rely on that.

  • Custom User Avatar

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

  • Custom User Avatar
    expected '[9,9,9,9,1,2,1,1,3,1,0,0,0,0,0,0,0,0,0,0]' to equal '[9,9,1,2,1,1,3,1,9,9,0,0,0,0,0,0,0,0,0,0]'
                your function returned this                               this was the expected value
    

    Fix your code.

  • Custom User Avatar

    Instructions: Write an algorithm that takes an array and moves ALL OF THE ZEROS to the END, PRESERVING the order of the other ELEMENTS.
    Log arr: [ 9, 0, 0, 9, 1, 2, 0, 1, 0, 1, 0, 3, 0, 1, 9, 0, 0, 0, 0, 9 ]

    expected '[9,9,9,9,1,2,1,1,3,1,0,0,0,0,0,0,0,0,0,0]' to equal '[9,9,1,2,1,1,3,1,9,9,0,0,0,0,0,0,0,0,0,0]'

    Where in the instructions it says that 9 needs to be moved to the beginning, fix it