Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
:thumb_up:
IMO it depends. Javascript is a chimera. Maybe you want to mutate the object! But in a pure functional world this is a sin.
Nice one with the "pageItemCount". I've done with 3 ifs :-)
Thats a nicely written and readable code. Great work!
man, i made my solution way extra longer. maybe i got intimidated by not knowing class/constructor Lol
wrapping all with a Math.abs() should do the trick
Isn't the
pageIndex
function wrong in case you ask for the last item at the end of the array (the item which equals tocollection.length
)?It's returning -1 instead of the page index that equals to the last page.
This works because the test used in this kata doesn't check for the very last item of the array.
This comment is hidden because it contains spoiler information about the solution
IMHO you should destructure you collection or create a new collection object elsewhere. With your current implementation a user cab mutate source collection (i.e. PaginationHelper.prototype.sortPages() etc).
Condition in
pageItemCount
is not correct;pageIndex
should be more or equal than zero, otherwise if it less, this method should return -1;The feint with min is really clever! Thanks to the author!
I don't like this string conversion having iterators in
Are you sure?