2018-10-08 13:34:43 -04:00
---
id: 587d8255367417b2b2512c72
title: Use .has and .size on an ES6 Set
localeTitle: Utilice .has y .size en un conjunto ES6
challengeType: 1
---
## Description
2018-10-09 20:28:15 +01:00
<section id='description'>
Veamos los métodos .has y .size disponibles en el objeto ES6 Set.
Primero, cree un conjunto ES6
<code>var set = new Set([1,2,3]);</code>
El método .has comprobará si el valor está contenido dentro del conjunto.
<code>var hasTwo = set.has(2);</code>
El método .size devolverá un número entero que representa el tamaño del Set
<code>var howBig = set.size;</code>
2018-10-08 13:34:43 -04:00
</section>
## Instructions
2018-10-09 20:28:15 +01:00
<section id='instructions'>
En este ejercicio pasaremos una matriz y un valor a la función checkSet (). Su función debe crear un conjunto ES6 a partir del argumento de la matriz. Encuentra si el conjunto contiene el argumento de valor. Encuentra el tamaño del conjunto. Y devuelve esos dos valores en una matriz.
2018-10-08 13:34:43 -04:00
</section>
## Tests
<section id='tests'>
```yml
tests:
2018-10-09 20:28:15 +01:00
- text: ' <code>checkSet([4, 5, 6], 3)</code> debe devolver [false, 3]'
2018-10-08 13:34:43 -04:00
testString: 'assert(function(){var test = checkSet([4,5,6], 3); test === [ false, 3 ]}, "<code>checkSet([4, 5, 6], 3)</code> should return [ false, 3 ]");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
function checkSet(arrToBeSet, checkValue){
// change code below this line
// change code above this line
}
checkSet([ 1, 2, 3], 2); // Should return [ true, 3 ]
```
</div>
</section>
## Solution
<section id='solution'>
```js
function checkSet(arrToBeSet, checkValue){
var set = new Set(arrToBeSet);
var result = [
set.has(checkValue),
set.size
];
return result;
}
```
</section>