pagination always show 5 pages

Solutions on MaxInterview for pagination always show 5 pages by the best coders in the world

showing results for - "pagination always show 5 pages"
Antonio
30 May 2016
1function pageRange(page,pageCount){
2
3var start = page-2,
4    end = page+2;
5
6if(end>pageCount){
7    start-=(end-pageCount);
8    end=pageCount;
9}
10if(start<=0){
11    end+=((start-1)*(-1));
12    start=1;
13}
14
15end = end>pageCount?pageCount:end;
16
17return {start:start, end:end};
18}
19