could anyone explain why the code:

`delete(value){ this.root = this.deleteNode(this.root, value) }`

isn’t actually changing the root node in the tree when it refers to `this.root`

. it is removing a leaf node, as desired, but i don’t understand why it doesn’t break the tree by reassigning it’s root.

(sorry, this is not following the excercise so code is incomplete)

```
**Your code so far**
```

```
.......
delete(value){
this.root = this.deleteNode(this.root, value)
}
deleteNode(node, value){
if(node === null){return node}
if(value < node.value){
node.left = this.deleteNode(node.left, value)
}else if(value > node.value){
node.right = this.deleteNode(node.right, value)
}else{
// THREE SCENARIA:
if(!node.left && !node.right){return null}
if(!node.left){return node.right}
else if(!node.right){return node.left}
// HAS 2 CHILDREN:
node.value = this.min(node.right)
node.right = this.deleteNode(node.right, node.value)
}
return node
}
}
const tree = new BinarySearchTree()
tree.add(10)
tree.add(5)
tree.add(15)
tree.add(3)
console.log('tree:',tree)
tree.delete(3)
console.log('tree:',tree)
```

```
**Your browser information:**
```

User Agent is: `Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.5060.134 Safari/537.36`

**Challenge:** Data Structures - Delete a Node with Two Children in a Binary Search Tree

**Link to the challenge:**