js/script.js
/*
Create the `addPagination` function
This function will create and insert/append the elements needed for the pagination buttons
*/
Create the `addPagination` function
This function will create and insert/append the elements needed for the pagination buttons
Create the ` addPagination ` function This function will create and insert / append the elements needed for the pagination buttons
function addPagination(list) {
  const pageCount = Math.ceil(list.length / itemsPerPage);
  for (let i = 1; i <= pageCount; i++) {
    let pageLink = `<li><button type="button">${i}</button></li>`;
    link.insertAdjacentHTML("beforeend", pageLink);
    link.querySelectorAll("button")[0].className = "active";
    link.addEventListener("click", (e) => {
      if (e.target.tagName === "BUTTON") {
        link.querySelector(".active").className = "";
        e.target.className = "active";
        showPage(list, e.target.textContent);
      }
    });
  }
}
function addPagination ( list ) { const pageCount = Math . ceil ( list . length / itemsPerPage ) ; for ( let i = 1 ; i <= pageCount ; i ++ ) { let pageLink = ` ${ i } ` ; link . insertAdjacentHTML ( "beforeend" , pageLink ) ; link . querySelectorAll ( "button" ) [ 0 ] . className = "active" ; link . addEventListener ( "click" , ( e ) => { if ( e . target . tagName === "BUTTON" ) { link . querySelector ( ".active" ) . className = "" ; e . target . className = "active" ; showPage ( list , e . target . textContent ) ; } } ) ; } }
Create the `addPagination` function
This function will create and insert/append the elements needed for the pagination buttons
Create the ` addPagination ` function This function will create and insert / append the elements needed for the pagination buttons
//provides amount of pages needed to display a max of 9 students per page