6 kyu

Sparse array split function

Description
Loading description...
Fundamentals
  • Please sign in or sign up to leave a comment.
  • Liandika Avatar

    I passed the test but I get two errors when I attempt the solution. The problem is, I don't know what the inputs are. I am unable to debug the test at this point. Printing the console log does not help as it does not clearly show which ones are arrays among the test inputs. Maybe I am unclear about the expected results of sparse array but at this point I find it difficult to debug my code. Does anyone have a useful tip or pointer that could help me?

    FIRST ERROR: Should return a split array: [[null],[null,null,0,""],[[null,null,null],[]]] Log Given array: ,,,,,,,,,,,,,,,,,,,,,,,,,,,,, END OF GIVEN Result: ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,

    SECOND ERROR: Should return a split array: [] Log Given array: 1,2,,3,4,,5,6,,7,8,,9 END OF GIVEN Result: 1,2,3,4,5,6,7,8,,9

  • Kees de Vreugd Avatar

    This comment has been hidden.

  • sasa97972 Avatar

    One of the test cases is broken:

    Receiving: [ null, <1 empty item>, undefined, null, 0, '', <1 empty item>, [ <3 empty items> ], [] ] Expected: [[null],[null,null,0,""],[ [null,null,null],[] ]]

  • Richard2957 Avatar

    This comment has been hidden.

  • LadaKalina Avatar

    Why in case of this input [ null, <1 empty item>, undefined, null, 0, '', <1 empty item>, [ <3 empty items> ], [] ] function should return [[null], [null, null, 0, ""], [[null, null, null], [] ]] instead of [ [ null ], [ undefined, null, 0, '' ], [ [ <3 empty items> ], [] ] ? I think it's a mistake in kata.

  • toni.g.m Avatar

    I think one of the test cases is broken.

    Receiving: [ null, <1 empty item>, undefined, null, 0, '', <1 empty item>, [ <3 empty items> ], [] ] Expected: [[null],[null,null,0,""],[ [null,null,null],[] ]]

    I get that it splits at the empty item, so [ [null] ]. However, after that, it just gets confusing. If [undefined, null, 0, ''] should evaluate to [null, null, 0, ""], then I would need to be able to check for 'undefined' in a way that doesn't catch empty fields. Not possible in Javascript. Empty fields /are/ undefined. So it should be [ [null], [null, 0, ''] ... ] ?

    It's also telling that in 3 years this kata was only completed successfully 14 times, and that at 6 kyu.

  • Blind4Basics Avatar

    tests are using test.expect instead of chai.assert.deepEqual

  • JohanWiltink Avatar

    If the original array is dense, for consistency .split() should return an array consisting of a copy of the original array.