From this javascript array
var test = [0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 1];
How can I do to get the result as displayed below. Thank you.
test = [[0],1,[0],1,1,1,[0,0],1,[0,0,0,0],1];
I have tried in many ways but I can't find a solution
test = test.reduce((_,$)=>$?[..._,$]:_.at(-1)?.[0]===0?(_.at(-1).push($),_):[..._,[$]],[]);