Created
August 23, 2017 04:24
-
-
Save Ai01/6bd0ca736dd4d424e9528e2b92084d3e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const arr = { | |
children: [1,2,3] | |
}; | |
arr.childrenGroup = []; | |
arr.children.reduce((r, e, index) => { | |
const lenghtOfChildren = qcSort.children.length; | |
if (index % 2 === 1) { | |
arr.childrenGroup.push([r,e]); | |
} else if (lenghtOfChildren % 2 === 1 && index === lenghtOfChildren - 1) { | |
arr.childrenGroup.push([e]); | |
} | |
return e; | |
}, null); | |
console.log(arr.childrenGroup); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment