Binary Search Tree

Test the code

node BST.js

Or if you have nodemon...

nodemon BST.js

I recommend to install nodemon if you want to test the functions

    npm install --save-dev nodemon

Explanations

first we are sorting the given array and putting it in the new Set constructor to remove duplicates. The new Set will return an object so we use the spread operator (...) to convert it into an array. I recently just learned about this.

[...new Set(array.sort((a, b) => a - b))];