Now that you have worked through ES5, you are going to perform something similar in ES6. This will be considerably easier. ES6 contains a built-in data structure <code>Set</code> so many of the operations you wrote by hand are now included for you. Let's take a look:
To create a new empty set:
<code>var set = new Set();</code>
You can create a set with a value:
<code>var set = new Set(1);</code>
You can create a set with an array:
<code>var set = new Set([1, 2, 3]);</code>
Once you have created a set, you can add the values you wish using the <code>add</code> method: