master
Matthew Huntington 3 years ago
parent 0cfd96b813
commit 6f9177bacf

@ -41,7 +41,7 @@ const breakDown = (node)=>{
const tree = breakDown({value:9}); const tree = breakDown({value:9});
console.dir(tree, {depth:null}); //console.dir(tree, {depth:null});
const getLeaves = (node)=>{ const getLeaves = (node)=>{
if(node.twoPath === undefined){ if(node.twoPath === undefined){
@ -58,8 +58,9 @@ const getLeaves = (node)=>{
if(Number.isInteger(twoPathRightValue[0])){ if(Number.isInteger(twoPathRightValue[0])){
twoPathRightValue.unshift(twoPathLeftValue); twoPathRightValue.unshift(twoPathLeftValue);
} else { } else {
twoPathRightValue[0].unshift(twoPathLeftValue) for(let subArray of twoPathRightValue){
twoPathRightValue[1].unshift(twoPathLeftValue); subArray.unshift(twoPathLeftValue);
}
} }
twoPathResult = twoPathRightValue; twoPathResult = twoPathRightValue;
} }
@ -97,7 +98,11 @@ const getLeaves = (node)=>{
if(Number.isInteger(threePathResult)){ if(Number.isInteger(threePathResult)){
twoPathResult.push(threePathResult) twoPathResult.push(threePathResult)
} else { } else {
twoPathResult.push(threePathResult[0]) if(Number.isInteger(threePathResult[0])){
twoPathResult.push(threePathResult)
} else {
twoPathResult = twoPathResult.concat(threePathResult);
}
} }
return twoPathResult; return twoPathResult;
} }

Loading…
Cancel
Save