Ad
  • Custom User Avatar

    pageIndex takes an item index and returns the page that it belongs on

    Because 0 is the item index, not the item itself.

  • Custom User Avatar

    When collection is 1...24, why in one of the test case (doTest(helper, 'pageIndex', 0, 0);).
    Position of 0 is on 0th page? when 0 is not even there!

  • Custom User Avatar

    Your code is failing these sample tests:

    	it ('empty collection', () => {
    		const empty = new PaginationHelper([], 10);
    
    		doTest(empty, 'pageCount', 0);
    		doTest(empty, 'itemCount', 0);
    		doTest(empty, 'pageIndex', -1, 0);
    		doTest(empty, 'pageItemCount', -1, 0);
    	});
    

    The collection is empty, so, there are no pages and no items, pageIndex should return -1 because there were no pages and pageItemCount from page 0 should also return -1 because it's an invalid page.

    Your code also have problems with the previous tests, it fails to return 0 for item 3 with pageIndex method. Not a kata issue.

  • Custom User Avatar

    ok, i understand there can be empty array in collection. but just clear out, when it should be 0 and when it should be -1

  • Custom User Avatar

    I don't think it's an issue:

    The types of values contained within the collection/array are not relevant.

    It means it can be anything. Read the post below yours.

  • Custom User Avatar

    In JS: Why collections are empty and trying to find number in test?

  • Custom User Avatar

    What is the format of Error.getting this:
    "alloc should return pointer: expected undefined to be a number or a date"

  • Custom User Avatar
  • Custom User Avatar

    Test/Attempt is not working:

    Expected 'true' on input of

    1 2 3 4 5 6 7 8 9
    1 2 3 4 5 6 7 8 9
    1 2 3 4 5 6 7 8 9
    1 2 3 4 5 6 7 8 9
    1 2 3 4 5 6 7 8 9
    1 2 3 4 5 6 7 8 9
    1 2 3 4 5 6 7 8 9
    1 2 3 4 5 6 7 8 9
    1 2 3 4 5 6 7 8 9
    : expected false to equal true
  • Custom User Avatar

    OP solved the task, closing

  • Custom User Avatar

    This kata helps force people to reevaluate how many passes their code does on the list in question. If you have nested loops, you'll likely hit timeouts for the lists with 10,000,000 elements, since even the fastest computers can't parse 10 million ^ 2 elements in a reasonable timeframe.

    I suggest looking up "memoization" :)

  • Default User Avatar

    no throwing: Execution Timed Out (12000 ms)

    i working amiwith for loop. Is this wrong for this kata should i use map or for each

  • Default User Avatar

    no i am not printing alot. The error happened, thats why i printed.

  • Default User Avatar

    you are possibly printing a lot. if so, silence the print statements and try again

  • Custom User Avatar

    Program is throwing error:

    Max Buffer Size Reached (1.5 MiB)

    Last attempt of array ([13,3,1,1,1,1,1,1,1,1,1,1,1,1...] , 13) does not complete;

  • Loading more items...