const books =[
{id: "1", name: "twilight", category: "Movies", price: 10},
{id: "2", name: "jaws", category: "Movies", price: 22},
{id: "3", name: "the shining", category: "Movies", price: 1},
{id: "4", name: "beers", category: "Movies", price: 10},
{id: "5", name: "apples", category: "Movies", price: 22},
{id: "6", name: "mono", category: "Movies", price: 1}
]
for(var i=0; i<books.length; i+=2){
var sliced = books.slice(i, i+2);
console.log(sliced);
}
Run code snippet
slice()
slice(start)
slice(start, end)