Set collections in JavaScript

Set collections allow you to create arrays without duplicates. Let's see how to work with such collections. First you need to create a collection with the following command:

javascriptlet set = new Set;

Once the collection has been created, new elements can be added to it using the add method:

javascriptlet set = new Set;

set.add(1);
set.add(2);
set.add(3);

At the same time, when trying to add an element that already exists in the collection, this element will not be added:

javascriptlet set = new Set;

set.add(1);
set.add(2);
set.add(3);
set.add(3); // will not be added, because it already exists
Задание 1

Create a Set collection. Use the add method to add elements to it. Make sure there are no duplicate elements added.