Ad
  • Custom User Avatar

    From the description: "Your function can modify the initial board value as much as you like, but the test suite will validate what you return, so don't forget to return it".

    But if you modify rows of the initial board then you will not pass tests. Tests call the user solution with a shallow copy of board.

  • Custom User Avatar

    It's not mentioned in the description that once two tiles are merged, no other tiles can be merged into that same tile within the same move. This only becomes apparent from test cases.

    example move row to left:
    
    row: [2, 0, 2, 4]
    expected: [4, 4, 0, 0]
    
    if multiple merges would be possible: [8, 0, 0, 0]
    
    
  • Custom User Avatar

    Set is a native class. You should not redefine it.

    User-defined classes ( ie, Constructor functions ) should, by convention, have names starting with a capital letter.

    Expecting "falsy" for null, undefined and NaN but not false, 0 or "" feels inconsistent. Easiest fix for that is possibly a different name, though I have trouble coming up with one that would naturally not include any of the others. Maybe you should just go with JS itself and expect "null" ( not the historically correct bug that is "object" ! ), "undefined" and "number".