回答編集履歴
1
ちょい修正
test
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
const a=[ 0,220, 20, 340, 0, 340, 34, 64, 0, 32, 12, 0, 23];
|
4
4
|
|
5
|
-
const b=a.reduce((x,y)=>y===0?x.push([])
|
5
|
+
const b=a.reduce((x,y)=>y===0?(x.push([]),x):(x[x.length-1].push(y),x),[[]]);
|
6
6
|
|
7
7
|
console.log(b);
|
8
8
|
|