js把一个数组的数据平均到几个数组里面

 

 arr 原始数组数据

count  每个数组里面元素个数

 

function splitIpLit(arr,count) {
let i = 0;
let newArr = [];
while(i < arr.length) {
newArr.push(arr.slice(i, i+=count));
}
return newArr;
}
let aaa = splitIpLit([1,2,3,4,5,6,7,8,9,0],5);
console.log(aaa)

posted @ 2021-12-23 18:01  Steven_Rain  阅读(177)  评论(0编辑  收藏  举报