* 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>
1.3 KiB
1.3 KiB
id, title, challengeType, forumTopicId, dashedName
id | title | challengeType | forumTopicId | dashedName |
---|---|---|---|---|
587d8255367417b2b2512c72 | Use .has and .size on an ES6 Set | 1 | 301717 | use--has-and--size-on-an-es6-set |
--description--
Let's look at the .has and .size methods available on the ES6 Set object.
First, create an ES6 Set
var set = new Set([1,2,3]);
The .has method will check if the value is contained within the set.
var hasTwo = set.has(2);
The .size method will return an integer representing the size of the Set
var howBig = set.size;
--instructions--
In this exercise we will pass an array and a value to the checkSet() function. Your function should create an ES6 set from the array argument. Find if the set contains the value argument. Find the size of the set. And return those two values in an array.
--hints--
checkSet([4, 5, 6], 3)
should return [ false, 3 ]
assert(
(function () {
var test = checkSet([4, 5, 6], 3);
return DeepEqual(test, [false, 3]);
})()
);
--seed--
--seed-contents--
function checkSet(arrToBeSet, checkValue){
// Only change code below this line
// Only change code above this line
}
--solutions--
function checkSet(arrToBeSet, checkValue){
var set = new Set(arrToBeSet);
var result = [
set.has(checkValue),
set.size
];
return result;
}