functioninvertBinaryTree(tree) {returninvertHelper(tree);}functioninvertHelper(node) {if (node ===null) {returnnull; }constleft=node.left;constright=node.right;node.right =invertHelper(node.left); // can not use node.right cuz you loose your reference from abovenode.left =invertHelper(right); return node;}// This is the class of the input binary tree.classBinaryTree {constructor(value) {this.value = value;this.left =null;this.right =null; }}// Do not edit the line below.exports.invertBinaryTree = invertBinaryTree;