Write a method returns a string representing the state of a pagination nav bar.
rule 1: the number of pages returned should not exceed the value of the 'maxVisiblePages'
parameter:
rule 1: always show the first page
rule 3: always show the last page
rule 4: put ellipse when appropriate
rule 5: place [] around the selected page and if possible, center it
paginate(1,30,11);
Output: "[1] 2 3 4 5 6 7 8 9 10 ... 30"
paginate(5,30,11);
Output: "1 2 3 4 [5] 6 7 8 9 10 ... 30"
input: 10, 30, 11
Output: 1 ... 6 7 8 9 [10] 11 12 13 14 ... 30
input: 24, 30, 11
output: 1 ... 20 21 22 23 [24] 25 26 27 28 ... 30
input: 30, 30, 11
output: 1 ... 21 22 23 24 25 26 27 28 29 [30]
function paginate(curPage, totalPages, maxVisiblePages) {
console.log(...arguments);
}