I am reviewing the solution to this leetcode problem. The solution is the following:
var maxDepth = function(root) {
let maxNode = (node, sum) => {
if (node === null) {
return sum;
}
return Math.max(maxNode(node.left, sum + 1), maxNode(node.right, sum + 1));
}
return maxNode(root, 0);
};
I was wondering why return maxNode(root, 0); must include a return. Is it required to 'activate' the inner function? If so, why doesn't just maxNode(root, 0) just 'activate' it?