Files
freeCodeCamp/curriculum/challenges/japanese/10-coding-interview-prep/data-structures/remove-items-from-a-set-in-es6.md
2022-01-20 20:30:18 +01:00

1.2 KiB

id, title, challengeType, forumTopicId, dashedName
id title challengeType forumTopicId dashedName
587d8254367417b2b2512c71 ES6 でセットから要素を削除する 1 301713 remove-items-from-a-set-in-es6

--description--

delete メソッドを使って ES6 のセットから要素を削除する方法を練習しましょう。

まず、ES6のセットを作成します。

var set = new Set([1,2,3]);

次に、delete メソッドを使用してセットから要素を削除します。

set.delete(1);
console.log([...set]) // should return [ 2, 3 ]

--instructions--

整数 1、2、3、4、5 を使ってセットを作成してください。

値 2 と 5 を削除してから、セットを返します。

--hints--

セットには、値 1、3、4 が含まれている必要があります。

assert(
  (function () {
    var test = checkSet();
    return test.has(1) && test.has(3) && test.has(4) && test.size === 3;
  })()
);

--seed--

--seed-contents--

function checkSet(){
  // Only change code below this line
  var set = null;

  // Only change code above this line
  return set;   
}

--solutions--

function checkSet(){
var set = new Set([1,2,3,4,5]);
set.delete(2);
set.delete(5);
return set;}