If I understand what your looking for. You have the const currentPage within the loop, so it will never be anything but 1 for every page.
Add this above the loop.
let currentPage = 0;
Then have this within the loop, before the createHeader()
currentPage++;
Should work better.