* 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.2 KiB
1.2 KiB
id, title, challengeType, videoUrl, dashedName
id | title | challengeType | videoUrl | dashedName |
---|---|---|---|---|
587d8255367417b2b2512c72 | 在ES6集上使用.has和.size | 1 | use--has-and--size-on-an-es6-set |
--description--
让我们看一下ES6 Set对象上可用的.has和.size方法。首先,创建一个ES6 Set var set = new Set([1,2,3]);
.has方法将检查该值是否包含在集合中。 var hasTwo = set.has(2);
.size方法将返回一个表示Set var howBig = set.size;
大小的整数var howBig = set.size;
--instructions--
在本练习中,我们将数组和值传递给checkSet()函数。您的函数应该从数组参数创建ES6集。查找该集是否包含value参数。找到集合的大小。并在数组中返回这两个值。
--hints--
checkSet([4, 5, 6], 3)
应该返回[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;
}