Ad
  • Custom User Avatar

    Oh and "Out of range" is like if you have an Array like [1, 3, 5] and you try to go to index 1000 or -1, anything other than 0(value:1), 1(3), 2(5) which actually exist in the array.

  • Custom User Avatar

    Make sure your console.log is the very first statement to run otherwise you risk something else blowing it up before it gets there.
    I would suggest a line like "console.log('pageIndex = ' + pageIndex);"
    If you're still having issues put this around your code:
    try {
    (your code here)
    } catch (error) {
    console.log("Exception: " + error.message);
    }
    Doing this will make it so if something is crashing your code, you'll at least get an error message back explaining what happened. Hopefully this helps, good luck.

  • Custom User Avatar

    I think there should be a test case where the object is initialized with an empty array and pageIndex(0) is called. This, in my opinion, should return a -1 as it is outside the range of an empty array.

    Example:

    helper = new PaginationHelper([], 10);
    Test.expect(helper.pageIndex(0) == -1, 'pageIndex returned incorrect value when provided a itemIndex argument that was out of range');

  • Custom User Avatar

    Oh, and it would be nice if you outlined that we needed to handle unacceptable inputs with exceptions (ie, 9 and higher, -9 and lower, 0) in the description of the kata.

  • Custom User Avatar

    You need to add a test case involving the user being rank 1 and completing a rank -1 activity, otherwise my original code would have worked. I was checking if I had passed the zero rank in my difference calculation by checking if the user rank was negative and the activity rank was positive.

    ex:
    var diff = rank - this.rank;
    diff = rank > 0 && this.rank < 0 ? diff - 1 : diff; //This shouldn't work but does currently, it needs to also check the inverse case

    Also, you need to have a test case where activity rank 0 is used, I forgot to cover that case but got by.

    Thanks for the kata though, it was a lot of fun.