Implement Root-to-Leaf Path Sum in JavaScript

# Introduction In this challenge, we'll implement the `hasPathSum` function in a JavaScript file. This function takes the binary tree root and an integer `targetSum` as input. The function's objective is to determine if there exists a path from root-to-leaf in the tree where the sum of values along the path equals the `targetSum`. The function will return `true` if such a path exists, and `false` if it does not. Two examples are provided to illustrate the problem and expected output.

|
60 : 00

Click the virtual machine below to start practicing