JSFiddle - React, Tailwind, and code Playground

by bilbobaggins

JavaScript

var array1 = ['abc','def', 'ghi', 'jkl','mno'];

function renderPagination(pageno, max_num){
    pageno -= 1; // arrays are zero indexed, so start from one less
    max_num += pageno; // max_num will be max_num + pageno
    
    // make sure max_num will not go out of bounds
    if(max_num > array1.length){
        max_num = array1.length;
    }
    
    for(pageno; pageno < max_num; pageno++){
        console.log(array1[pageno]);
    }
}
renderPagination(1, 3);