title: How create function to universal pagination?
body: <p>How create generic function to form the pagination array.The function receives 2 numbers (totalPage, currentPage). Need to do as in the example &quot;Only page numbers&quot; on <a href="https://pagination.js.org" rel="nofollow noreferrer">https://pagination.js.org</a> Started doing the implementation, but so far unsuccessfully <a href="https://jsfiddle.net/insider73/7u1j9Let/2/" rel="nofollow noreferrer">jsfiddle</a></p>
  <pre><code>let calculatePaginationItems = (totalPage,currentPage) =&gt; {
      let arr = new Array;
      if(totalPage &gt; 6) {
            for(let i = currentPage; i &lt; totalPage + 1; i++) {
      
              if((currentPage &lt; ((currentPage + 3) - i) + currentPage) || i &gt; totalPage - 3) {
                arr.push(i)
              }
              if(i === currentPage + 4) {
                arr.push('...')
              }
            }
          } else {
            for(let i = 1;i &lt; totalPage + 1;i++){
              arr.push(i)
            }
          }
          console.log(arr);
      }
      
      calculatePaginationItems(100,50)
      calculatePaginationItems(100,99)
      calculatePaginationItems(7,7)
  </code></pre>