Invert Binary Tree

Binary search tree (BST) construction and its properties is covered here

Given the root of a binary tree, invert the tree.

Example:

Tree:
    2
  /   \
 1     3

Inverted Tree:
    2
  /   \
 3     1

Input: [2,1,3]
Output: [2,3,1]

Solution:

 var invertTree = function(root) {
     if(root==null)return root;
     
     var temp = root.left;
     root.left = root.right;
     root.right = temp;
     
     invertTree(root.left);
     invertTree(root.right);
     
     return root;
 };
"Be so good they can't ignore you." - Steve Martin