Files
freeCodeCamp/curriculum/challenges/english/08-coding-interview-prep/data-structures/use-spread-and-notes-for-es5-set-integration.english.md
Andrew Zaw 6f4a9ed721 Reorganized instruction text on multiple challenges (#35912)
* Reorganized instruction text on multiple challenges

* Fixed spaces

* Fixed spaces again

* Update curriculum/challenges/english/08-coding-interview-prep/data-structures/add-elements-at-a-specific-index-in-a-linked-list.english.md

Co-Authored-By: Randell Dawson <5313213+RandellDawson@users.noreply.github.com>

* Update curriculum/challenges/english/08-coding-interview-prep/data-structures/find-the-minimum-and-maximum-height-of-a-binary-search-tree.english.md

Co-Authored-By: Randell Dawson <5313213+RandellDawson@users.noreply.github.com>

* fix: added code tags
2019-06-20 13:16:31 -04:00

66 lines
1.3 KiB
Markdown

---
id: 587d8255367417b2b2512c73
title: Use Spread and Notes for ES5 Set() Integration
challengeType: 1
---
## Description
<section id='description'>
Do you remember the ES6 spread operator <code>...</code>?
<code>...</code> 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 ]
```
</section>
## Instructions
<section id='instructions'>
In this exercise we will pass a set object to the <code>checkSet</code> function. It should return an array containing the values of the Set.
Now you've successfully learned how to use the ES6 <code>Set()</code> object, good job!
</section>
## Tests
<section id='tests'>
```yml
tests:
- text: Your Set was returned correctly!
testString: 'assert((function(){var test = checkSet(new Set([1,2,3,4,5,6,7])); return DeepEqual(test, [ 1, 2, 3, 4, 5, 6, 7 ]);})(), "Your Set was returned correctly!");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
function checkSet(set){
// change code below this line
// change code above this line
}
```
</div>
</section>
## Solution
<section id='solution'>
```js
function checkSet(set){
return [...set];}
```
</section>