Pagination calculation
From a short review;


You use globals instead of parameters for activePage and pageNeighbours
You need at least one comment stating what pageNeighbours stands for, without knowing this the code looks meaningless to me
You need at least one comment on the top explaining what the range is supposed to contain
On the whole I think this could use more comments
Why actualPageRange instead of simply pageRange, or even range since it would be clear from context what range we're reading about


Okay, so since the code does not work, expect this question to be closed.
That doesn't mean that functionally this isn't a great question.

This is my approach to what I believe you are looking for:

const pageRange = ((activePage, pageNeighbours, totalPages) =&gt; {

  let range = [];
  //Add active page and neighbouring pages
  for(let page = activePage - pageNeighbours; page &lt;= activePage + pageNeighbours; page++)
    range.push(page);
  //Make sure we dont show pages that dont exist
  range = range.filter(page=&gt; page &gt; 0 &amp;&amp; page &lt;= totalPages);
  //Allow user to go to the first page if need be
  //The second entry should be either 2 or ellipsis(...)
  if(range[0]!=1){
    if(range[1]!=2){
      range.unshift('...');
    }
    range.unshift(1);
  }
  //Allow user to go the last page, second last entry should be second last page or ellipsis
  if(range[range.length-1] != totalPages){
    if(range[range.length-2]!= totalPages-1){
      range.push('...');
    }  
    range.push(totalPages);
  }

  return range;
})(activePage, pageNeighbours, totalPages);


Note that this avoids accessing activePage etc. as a global.