freeCodeCamp/curriculum/challenges/english/08-coding-interview-prep/data-structures/use-spread-and-notes-for-es5-set-integration.english.md
Randell Dawson c25fa49b5b fix(curriculum): changed test text to use should for Coding Interview Prep - part 1 of 2 (#37765)
* fix: changed test text to use should

* fix: corrected typo

Co-Authored-By: Tom <20648924+moT01@users.noreply.github.com>

* fix: corrected typo

Co-Authored-By: Tom <20648924+moT01@users.noreply.github.com>

* fix: corrected typo

Co-Authored-By: Tom <20648924+moT01@users.noreply.github.com>

* fix: use singular of verb

Co-Authored-By: Tom <20648924+moT01@users.noreply.github.com>

* fix: changed punctuation

Co-Authored-By: Tom <20648924+moT01@users.noreply.github.com>

* fix: reworded test text

Co-Authored-By: Tom <20648924+moT01@users.noreply.github.com>
2019-11-19 20:13:45 -05:00

1.3 KiB

id, title, challengeType, forumTopicId
id title challengeType forumTopicId
587d8255367417b2b2512c73 Use Spread and Notes for ES5 Set() Integration 1 301720

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.
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!

Tests

tests:
  - text: <code>checkSet(new Set([1,2,3,4,5,6,7])</code> should return <code>[1, 2, 3, 4, 5, 6, 7]</code>.
    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 ]);})());'

Challenge Seed

function checkSet(set){
   // change code below this line

   // change code above this line
}

Solution

function checkSet(set){
return [...set];}