diff --git a/random.js b/random.js index cffd841..11c62c2 100644 --- a/random.js +++ b/random.js @@ -39,7 +39,7 @@ const breakDown = (node)=>{ return node; } -const tree = breakDown({value:9}); +const tree = breakDown({value:10}); //console.dir(tree, {depth:null}); @@ -76,8 +76,9 @@ const getLeaves = (node)=>{ if(Number.isInteger(threePathRightValue[0])){ threePathRightValue.unshift(threePathLeftValue); } else { - threePathRightValue[0].unshift(threePathLeftValue) - threePathRightValue[1].unshift(threePathLeftValue); + for(let subArray of threePathRightValue){ + subArray.unshift(threePathLeftValue); + } } threePathResult = threePathRightValue; }