Simple JS DFS
The way I think about it: \nWould top down or bottom up work best for this? - I think bottom up, so that we can calculate the total at each node as we go toward
The way I think about it: \nWould top down or bottom up work best for this? - I think bottom up, so that we can calculate the total at each node as we go towards the top\n\nSo...\nLets go DFS and Inorder, at each node, we find the total sums as we traverse down again. \nThis means that we are bubbling up, and doing a dfs at each node with another function. \n\nI hope this helps someone!\n\n\n```\nvar pathSum = function(root, targetSum) {\n    if(!root) return 0;\n    let count = 0;\n    \n    function helper(node, sum){\n        if(!node) return;\n\t\t//traversing down the tree again, add up the sum\n        sum += node.val;\n        if(sum === targetSum) count++;\n        return helper(node.left, sum) || helper(node.right, sum)\n    }\n    \n    \n    function dfs(node){\n        if(!node) return;\n\t\t\n\t\t//inorder\n        node.left && dfs(node.left);\n        helper(node, 0); //instantiate a new sum of 0 at each node\n        node.right && dfs(node.right);\n    }\n    \n    dfs(root);\n    return count;\n};\n```
['Depth-First Search', 'Recursion', 'JavaScript']