The next method we will implement is the add method, as follows:
add(element) { if (!this.has(element)) { this.items[element] = element; // {1} return true; } return false;}
Given an element, we can check whether the element already exists in the set. If not, we add the element to the set ({1}) and return true to indicate that the element was added. If the element already exists in the set, we simply return false to indicate that the element was not added.