1.3 KiB
1.3 KiB
id | title | challengeType |
---|---|---|
587d8255367417b2b2512c73 | Use Spread and Notes for ES5 Set() Integration | 1 |
Description
...
?
...
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
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: 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!");'
Challenge Seed
function checkSet(set){
// change code below this line
// change code above this line
}
Solution
function checkSet(set){
return [...set];}