UNPKG

ds-algo-study

Version:

Just experimenting with publishing a package

22 lines (19 loc) 450 B
class Node { constructor(data) { this.data = data; this.left = null; this.right = null; } insert(data) { if (data < this.data && this.left) { this.left.insert(data); } else if (data < this.data) { this.left = new Node(data); } else if (data > this.data && this.right) { this.right.insert(data); } else if (data > this.data) { this.right = new Node(data); } } } module.exports = Node;