JavaScript DFS straightforward two methods
\nvar pathSum = function(root, sum) {\n    let res = 0;\n    const helper = (root, sum) => {\n        if(!root) return;\n        sum -= root.val;\n        if(su
```\nvar pathSum = function(root, sum) {\n    let res = 0;\n    const helper = (root, sum) => {\n        if(!root) return;\n        sum -= root.val;\n        if(sum === 0){\n            res++;\n        }\n        helper(root.left, sum);\n        helper(root.right, sum);\n    }\n    const main = (root, sum) => {\n        if(!root) return 0;\n        helper(root, sum);\n        main(root.left, sum);\n        main(root.right, sum);\n        return ;\n    }\n    main(root, sum);\n    return res;\n};\n\n\n```
['Depth-First Search', 'JavaScript']