freeCodeCamp/curriculum/challenges/chinese/10-coding-interview-prep/data-structures/use-spread-and-notes-for-es5-set-integration.md
Oliver Eyton-Williams ee1e8abd87
feat(curriculum): restore seed + solution to Chinese (#40683)
* 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>
2021-01-12 19:31:00 -07:00

52 lines
1.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
id: 587d8255367417b2b2512c73
title: 使用Spread和Notes进行ES5 Set集成
challengeType: 1
videoUrl: ''
dashedName: use-spread-and-notes-for-es5-set-integration
---
# --description--
你还记得ES6传播运营商`...` `...`可以在ES6中获取可迭代对象并将它们转换为数组。让我们创建一个Set并检查传播函数。
> var set = new Set\[1,2,3];
> var setToArr = \[... set]
> console.logsetToArr//返回\[1,2,3]
# --instructions--
在本练习中我们将set对象传递给`checkSet`函数。它应该返回一个包含Set值的数组。现在你已经成功学会了如何使用ES6 `Set()`对象,干得好!
# --hints--
您的套装已正确退回!
```js
assert(
(function () {
var test = checkSet(new Set([1, 2, 3, 4, 5, 6, 7]));
return DeepEqual(test, [1, 2, 3, 4, 5, 6, 7]);
})()
);
```
# --seed--
## --seed-contents--
```js
function checkSet(set){
// Only change code below this line
// Only change code above this line
}
```
# --solutions--
```js
function checkSet(set){
return [...set];}
```