# freeCodeCamp Challenge Guide: Create and Add to Sets in ES6

**URL:** <https://forum.freecodecamp.org/t/freecodecamp-challenge-guide-create-and-add-to-sets-in-es6/301636>\
**Category:** freeCodeCamp Contributors\
**Tags:** guide\
**Created:** [August 3, 2019, 1:26pm UTC](https://forum.freecodecamp.org/t/freecodecamp-challenge-guide-create-and-add-to-sets-in-es6/301636 "2019-08-03T13:26:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![camperbot](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/camperbot/32/18364_2.png) [@camperbot](https://forum.freecodecamp.org/u/camperbot)\
**Post date:** [August 3, 2019, 1:26pm UTC](https://forum.freecodecamp.org/t/freecodecamp-challenge-guide-create-and-add-to-sets-in-es6/301636/1 "2019-08-03T13:26:51Z")

</div>

# [Create and Add to Sets in ES6](https://www.freecodecamp.org/learn/coding-interview-prep/data-structures/create-and-add-to-sets-in-es6)

* * *

## Problem Explanation

To solve this problem, you have to add an array of items to the set.

* * *

## Hints

### Hint 1

Use the add function to add an array of strings to the set.

### Hint 2

Use the length attribute on the values of the Set.

* * *

## Solutions

> **Solution 1 (Click to Show/Hide)**
>
> ```js
> function checkSet() {
> var set = new Set([1, 2, 3, 3, 2, 1, 2, 3, 1]);
> set.add("Taco");
> set.add("Cat");
> set.add("Awesome");
> console.log(Array.from(set));
> return set;
> }
> 
> checkSet();
> 
> ```
> 
> #### Code Explanation
> 
> - Creating a set object as shown in pre-written code will create the set without duplicate objects.
> - Therefore, by using the add function, we can add items to the set and they will not be duplicated, and will still be represented in the array.

---

<div class="post-metadata">

**Author:** ![ILM](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ilm/32/363239_2.png) [@ILM](https://forum.freecodecamp.org/u/ILM)\
**Post date:** [January 8, 2025, 3:51pm UTC](https://forum.freecodecamp.org/t/freecodecamp-challenge-guide-create-and-add-to-sets-in-es6/301636/2 "2025-01-08T15:51:14Z")

</div>

Closed on January 8, 2025, 3:51pm UTC


