script.js
script.js
function showProducts(page) {
const startIndex = (page - 1) * productsPerPage;
const endIndex = startIndex + productsPerPage;
const productsToDisplay = products.slice(startIndex, endIndex);
function nextPage() {
if (currentPage < Math.ceil(products.length / productsPerPage)) {
currentPage++;
showProducts(currentPage);
}
}
function prevPage() {
if (currentPage > 1) {
currentPage--;
showProducts(currentPage);
}
}