Fix 'Creating and Adding to Sets in ES6' challenge
parent
4ded8169cb
commit
312e66d6cf
|
@ -674,31 +674,34 @@
|
|||
"id": "587d8254367417b2b2512c70",
|
||||
"title": "Creating and Adding to Sets in ES6",
|
||||
"description": [
|
||||
"Now we have worked through ES5, we are going to perform similar actions in ES6. This will be considerably easier. Set is now now a provided data structure like Object, Array, etc. so many of the operations we wrote by hand are now included for us. Let's take a look:",
|
||||
"Now that you have worked through ES5, you are going to perform something similar in ES6. This will be considerably easier. ES6 contains a built-in data structure <code>Set</code> so many of the operations you wrote by hand are now included for you. Let's take a look:",
|
||||
"To create a new empty set:",
|
||||
"var set = new Set();",
|
||||
"<code>var set = new Set();</code>",
|
||||
"You can create a set with a value:",
|
||||
"var set = new Set(1);",
|
||||
"<code>var set = new Set(1);</code>",
|
||||
"You can create a set with an array:",
|
||||
"var set = new Set([1,2,3]);",
|
||||
"Once you have created a set, you can add the values you wish using set.add:",
|
||||
"var set = new Set([1,2,3]);",
|
||||
"set.add([4,5,6]);",
|
||||
"For this exercise, we will return a set with the following values: 1, 2, 3, 'Taco', 'Cat', 'Awesome'",
|
||||
"Test suite (using the assert method)",
|
||||
"assert((function(){var test = checkSet(); var testArr = [...test]; testArr === [ 1, 2, 3, 'Taco', 'Cat', 'Awesome'])}, 'message: Your Set was returned correctly!');"
|
||||
"<code>var set = new Set([1, 2, 3]);</code>",
|
||||
"Once you have created a set, you can add the values you wish using the <code>add</code> method:",
|
||||
"<blockquote>var set = new Set([1, 2, 3]);<br>set.add([4, 5, 6]);</blockquote>",
|
||||
"As a reminder, a set is a data structure that cannot contain duplicate values:",
|
||||
"<blockquote>var set = new Set([1, 2, 3, 1, 2, 3]);<br>// set contains [1, 2, 3] only</blockquote>",
|
||||
"<hr>",
|
||||
"For this exercise, return a set with the following values: <code>1, 2, 3, 'Taco', 'Cat', 'Awesome'</code>"
|
||||
],
|
||||
"challengeSeed": [
|
||||
"function checkSet(){",
|
||||
" var set = new Set([1,2,3,3,2,1,2,3,1]);",
|
||||
" // change code below this line",
|
||||
" // change code above this line",
|
||||
" console.log(set)",
|
||||
"};",
|
||||
"function checkSet() {",
|
||||
" var set = new Set([1, 2, 3, 3, 2, 1, 2, 3, 1]);",
|
||||
" // change code below this line",
|
||||
" ",
|
||||
" // change code above this line",
|
||||
" console.log(set);",
|
||||
" return set;",
|
||||
"}",
|
||||
"",
|
||||
"checkSet();"
|
||||
],
|
||||
"tests": [
|
||||
"assert((function(){var test = checkSet(); var testArr = [...test]; testArr === [ 1, 2, 3, 'Taco', 'Cat', 'Awesome'])}, 'message: Your Set was returned correctly!');"
|
||||
"assert((function(){var test = checkSet(); return (test.size == 6) && test.has(1) && test.has(2) && test.has(3) && test.has('Taco') && test.has('Cat') && test.has('Awesome');})(), 'message: Your <code>Set</code> only contains the values <code>1, 2, 3, Taco, Cat, Awesome</code>.');"
|
||||
],
|
||||
"type": "waypoint",
|
||||
"releasedOn": "Feb 17, 2017",
|
||||
|
|
Loading…
Reference in New Issue