freeCodeCamp/curriculum/challenges/chinese/10-coding-interview-prep/data-structures/use-spread-and-notes-for-es5-set-integration.md
2020-10-06 23:10:08 +05:30

1.2 KiB
Raw Blame History

id, challengeType, videoUrl, title
id challengeType videoUrl title
587d8255367417b2b2512c73 1 使用Spread和Notes进行ES5 Set集成

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()对象,干得好!

Tests

tests:
  - text: 您的套装已正确退回!
    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 ]);})());'

Challenge Seed

function checkSet(set){
   // change code below this line

   // change code above this line
}

Solution

// solution required

/section>