From 40bcb50cdd13db4e38215184a9d16d4237c55170 Mon Sep 17 00:00:00 2001 From: Matthew Huntington Date: Wed, 19 Apr 2023 15:01:54 -0400 Subject: [PATCH] 8 almost works --- random.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/random.js b/random.js index 4f47163..81b366c 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:8}); console.dir(tree, {depth:null}); @@ -72,8 +72,13 @@ const getLeaves = (node)=>{ threePathResult[0] = threePathLeftValue; threePathResult[1] = threePathRightValue; } else { - threePathResult[0] = threePathLeftValue; - threePathResult = threePathResult.concat(threePathRightValue); + if(Number.isInteger(threePathRightValue[0])){ + threePathRightValue.unshift(threePathLeftValue); + } else { + threePathRightValue[0].unshift(threePathLeftValue) + threePathRightValue[1].unshift(threePathLeftValue); + } + threePathResult = threePathRightValue; } }