Separate javascript object into groups with 4 items in the click event!

0

Personal how do I split a javascript object into groups with 4 items each? follows an example of how the array or object should stay, but I would like to know how I can create a function so that when the user clicks a button, 4 of those items are displayed in the html .. when clicking again it should display 4 more until it has not more items to display! Thank you.

var obj = [
    'item1',
    'item2',
    'item3',
    'item4',
    'item5',
    'item6',
    'item7',
    'item8',
    'item9',
    'item10',
    'item11'
]

console.log(obj.slice(0, 4));    
console.log(obj.slice(4, 8));
console.log(obj.slice(8, 12));
    
asked by anonymous 06.07.2018 / 03:50

0 answers