freeCodeCamp/curriculum/challenges/portuguese/08-coding-interview-prep/data-structures/remove-items-from-a-set-in-...

1.4 KiB

id title challengeType videoUrl localeTitle
587d8254367417b2b2512c71 Remove items from a set in ES6 1 Remover itens de um conjunto no ES6

Description

Vamos praticar itens de remoção de um conjunto ES6 usando o método delete . Primeiro, crie um conjunto ES6 var set = new Set([1,2,3]); Agora, remova um item do seu conjunto com o método de delete .
set.delete (1);
console.log ([... set]) // deve retornar [2, 3]

Instructions

Agora, crie um conjunto com os números inteiros 1, 2, 3, 4 e 5. Remova os valores 2 e 5 e, em seguida, retorne o conjunto.

Tests

tests:
  - text: 'Seu conjunto deve conter os valores 1, 3 e 4'
    testString: 'assert(function(){var test = checkSet(); return test.has(1) && test.has(3) && test.has(4) && test.size === 3}, "Your Set should contain the values 1, 3, & 4");'

Challenge Seed

function checkSet(){
   var set = //Create a set with values 1, 2, 3, 4, & 5
   //Remove the value 2
   //Remove the value 5
   //Return the set
   return set;
}

Solution

// solution required