I would like such a function, I can’t write myself yet, I can’t think how to divide an array by positions.
It should work like this arraySplit(array, el => return el ? true : false);
And from the array of elements
[item, item, item, NOPE, item, item, NOPE, item, item] Do
[[item,item,item], [item,item,item], [item, item]] DreamChild Solution
export function arraySplit(el, separator) { const items = Array.from(document.querySelectorAll(el)); let tmp = []; if (!items) { return tmp; } let res = [tmp]; for (let item of items) { if (!separator(item)) { tmp.push(item); } else { tmp = []; res.push(tmp); } } return res; }