Chunk an Array into Size N
let arr = [1,2,3,4,5]
let n = 3
function chunkArray(arr, n){
let res=[]
for(let i=0;i<arr.length;i+=n){
res.push(arr.slice(i, i+n))
}
return res;
}
const d = chunkArray(arr, n)
console.log(d)
Chunk an Array into Size N
let arr = [1,2,3,4,5]
let n = 3
function chunkArray(arr, n){
let res=[]
for(let i=0;i<arr.length;i+=n){
res.push(arr.slice(i, i+n))
}
return res;
}
const d = chunkArray(arr, n)
console.log(d)
For further actions, you may consider blocking this person and/or reporting abuse
Top comments (0)