701-insert-into-a-binary-search-tree

DevGod needs to write a blog entry for this problem!
/**
 * Definition for a binary tree node.
 * function TreeNode(val, left, right) {
 *     this.val = (val===undefined ? 0 : val)
 *     this.left = (left===undefined ? null : left)
 *     this.right = (right===undefined ? null : right)
 * }
 */
/**
 * @param {TreeNode} root
 * @param {number} val
 * @return {TreeNode}
 */
var insertIntoBST = function(root, val) {
    if(root === null){
        return new TreeNode(val);
    }

    if(val < root.val){
        root.left = insertIntoBST(root.left, val);
    }else{
       root.right = insertIntoBST(root.right, val); 
    }

    return root;
};