freeCodeCamp/curriculum/challenges/english/10-coding-interview-prep/data-structures/use-spread-and-notes-for-es5-set-integration.md
Oliver Eyton-Williams ee1e8abd87
feat(curriculum): restore seed + solution to Chinese (#40683)
* feat(tools): add seed/solution restore script

* chore(curriculum): remove empty sections' markers

* chore(curriculum): add seed + solution to Chinese

* chore: remove old formatter

* fix: update getChallenges

parse translated challenges separately, without reference to the source

* chore(curriculum): add dashedName to English

* chore(curriculum): add dashedName to Chinese

* refactor: remove unused challenge property 'name'

* fix: relax dashedName requirement

* fix: stray tag

Remove stray `pre` tag from challenge file.

Signed-off-by: nhcarrigan <nhcarrigan@gmail.com>

Co-authored-by: nhcarrigan <nhcarrigan@gmail.com>
2021-01-12 19:31:00 -07:00

60 lines
1.1 KiB
Markdown

---
id: 587d8255367417b2b2512c73
title: Use Spread and Notes for ES5 Set() Integration
challengeType: 1
forumTopicId: 301720
dashedName: use-spread-and-notes-for-es5-set-integration
---
# --description--
Do you remember the ES6 spread operator `...`?
`...` can take iterable objects in ES6 and turn them into arrays.
Let's create a Set, and check out the spread function.
```js
var set = new Set([1,2,3]);
var setToArr = [...set]
console.log(setToArr) // returns [ 1, 2, 3 ]
```
# --instructions--
In this exercise we will pass a set object to the `checkSet` function. It should return an array containing the values of the Set.
Now you've successfully learned how to use the ES6 `Set()` object, good job!
# --hints--
`checkSet(new Set([1,2,3,4,5,6,7])` should return `[1, 2, 3, 4, 5, 6, 7]`.
```js
assert(
(function () {
var test = checkSet(new Set([1, 2, 3, 4, 5, 6, 7]));
return DeepEqual(test, [1, 2, 3, 4, 5, 6, 7]);
})()
);
```
# --seed--
## --seed-contents--
```js
function checkSet(set){
// Only change code below this line
// Only change code above this line
}
```
# --solutions--
```js
function checkSet(set){
return [...set];}
```