How do I page counter with divide?

I need to make page counter from server data with page limit. e,g, when I get 8 items from server, I was used like this.

let pageCounter = parseInt(TotalData / PageLimit);

If PageLimit is 5 items, we might set page Counter as 2 pages. But, If I use above divide logic, I can get only 1 page.

Who know about this as well?

Answer

This can be done using the Math.ceil function.

let pageCounter=TotalData < PageLimit ? 1 : Math.ceil(TotalData / PageLimit);

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/ceil