can someone explain leetcode Question #2236

Viewed 17

This is my first time doing a leetcode and I got a binary tree problem (also my first seeing it) although the question seems easy enough I'm having a hard time understanding this specifically

 * function TreeNode(val, left, right) {
 *     this.val = (val===undefined ? 0 : val)
 *     this.left = (left===undefined ? null : left)
 *     this.right = (right===undefined ? null : right)
 * }

what does the ? 0 : val) mean after the undefined? screenshot of leetcode question

leet link: https://leetcode.com/problems/root-equals-sum-of-children/

0 Answers
Related