Skip to content

Commit fa30ca4

Browse files
authored
Update 2331-evaluate-boolean-binary-tree.js
Make if statement as one.
1 parent a1307b8 commit fa30ca4

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

javascript/2331-evaluate-boolean-binary-tree.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ var evaluateTree = function(root) {
1818
};
1919

2020
const dfs = (node) => {
21-
if (!node.left && !node.right && node.val) return true;
22-
if (!node.left && !node.right && !node.val) return false;
21+
if (!node.left && !node.right) return (node.val) ? true : false;
2322

2423
const is2 = (node.val === 2);
2524
if (is2) return dfs(node.left) || dfs(node.right);

0 commit comments

Comments
 (0)