let arr = ["a", "b", "c", "d", "e", "f", "g"]
const fn = (arr, ...rest) => {
let temp = []
for (let i = 0; i < rest.length; i++) {
temp.push(arr.splice(0, rest[i]))
}
return temp
}
let res = fn(arr, 2, 2, 2, 1)
console.log(res)
let arr = ["a", "b", "c", "d", "e", "f", "g"]
const fn = (arr, ...rest) => {
let temp = []
for (let i = 0; i < rest.length; i++) {
temp.push(arr.splice(0, rest[i]))
}
return temp
}
let res = fn(arr, 2, 2, 2, 1)
console.log(res)