例如我有一个块数组,这个数组有各个块的大小。
let example = [3,3]; // Chunks array
let auxarrayindex = [1,2,3,4,5,6]; // Array that I want to splice
let example2 = [3,2,3]; // Chunks array
let auxarrayindex2 = [1,2,3,4,5,6,7,8]; // Array that I want to splice
我想要的结果是:
[1,2,3],[4,5,6] and the second [1,2,3],[4,5],[6,7,8]
这是我的代码:
for (let auxexample = 0; auxexample < example.length; auxexample++) {
finalauxarray.push(auxarrayindex.slice(0, example[auxexample]));
}
我的代码的结果是:
[1,2,3],[1,2,3] and the second [1,2,3],[1,2],[1,2,3]
慕码人2483693
侃侃无极
梦里花落0921
相关分类