Files
freeCodeCamp/curriculum/challenges/ukrainian/10-coding-interview-prep/data-structures/use-spread-and-notes-for-es5-set-integration.md

60 lines
1.5 KiB
Markdown
Raw Permalink 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
forumTopicId: 301720
dashedName: use-spread-and-notes-for-es5-set-integration
---
# --description--
Пригадуєте оператора розкидання ES6 `...`?
`...` може підібрати об'єкти-ітератори в ES6 і перетворити їх на масиви.
Створімо Set та перевіримо функцію spread.
```js
var set = new Set([1,2,3]);
var setToArr = [...set]
console.log(setToArr) // returns [ 1, 2, 3 ]
```
# --instructions--
У цій вправі ми передамо заданий об'єкт до функції `checkSet`. Функція повинна повернути масив, що містить значення обʼєкта Set.
Тепер ви успішно дізналися, як використовувати об'єкт ES6 `Set()`. Гарна робота!
# --hints--
Функція `checkSet(new Set([1,2,3,4,5,6,7])` повинна повернути `[1, 2, 3, 4, 5, 6, 7]`.
```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];}
```