Ad
  • Default User Avatar

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

  • Custom User Avatar

    From the instructions:

    This reader expose only one method : getChunk()
    
    Returns the following fragment of text from the file it is reading
    Returns a string of random size
    Returns at least one char
    Returns an empty string when finished
    

    In the instructions, it states that the getChunk function exposed by the reader "Returns at least one char".
    One of the test cases, the first chunk received by the parse method is an empty string (so the entire string it was reading must be an empty string), thus making the charCount, wordCount, and lineCount expected to be 0.
    Even if it was allowed that the first string received by getChunk was an empty string, there are other tests where there are empty lines that count as a line, so wouldn't an empty string test case still have a lineCount of 1?

    Example:

    chunk = 'foo\n\nbar'
    expected result:
    charCount: 6
    wordCount: 2
    lineCount: 3
    

    and if that's the case, then shouldn't this be true:

    chunk = ''
    charCount: 0
    wordCount: 0
    lineCount: 1
    
  • Default User Avatar

    Is this a bug or did I just misunderstood something?
    I tried to console.log the output within parse() and it seems like I get correct char, word, and line counts (on the initial test case: "Once upon a time")

    This error shows upon Test (not on submit)

    TypeError: Cannot read properties of undefined (reading 'getChunk')
        at DocumentParser.parse (test.js:54:21)
        at Context.<anonymous> (test.js:93:12)
        at process.processImmediate (node:internal/timers:471:21)
    

    Appreciate any feedback :)

  • Default User Avatar

    I found the introduction of .reset method a bit misleading. I thought .reset method would serve some specific purpose (like resetting the values during calculating something etc.), but it turns out .reset doesn't actually "reset" anything, it merely declares and initializes the three properties to value 0. Seems like there's no need to "reset" anything in this kata. I was thinking there's something wrong with my solutions as they didn't make any "resetting" use of the method. Other Codewarriors' solutions don't make use of it either (apart from just declaring and initializing the three properties). Introducing .reset method only created unnecessary confusion imo, it should have been omitted or named differently (e.g. .initialCounts).
    Also, I'd would be nice to state in kata description whether we're allowed to modify the code in .reset method and in Reader constructor.

  • Default User Avatar

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

  • Custom User Avatar

    No random tests.