* Reorganized instruction text on multiple challenges * Fixed spaces * Fixed spaces again * Update curriculum/challenges/english/08-coding-interview-prep/data-structures/add-elements-at-a-specific-index-in-a-linked-list.english.md Co-Authored-By: Randell Dawson <5313213+RandellDawson@users.noreply.github.com> * Update curriculum/challenges/english/08-coding-interview-prep/data-structures/find-the-minimum-and-maximum-height-of-a-binary-search-tree.english.md Co-Authored-By: Randell Dawson <5313213+RandellDawson@users.noreply.github.com> * fix: added code tags
1.3 KiB
1.3 KiB
id, title, challengeType
id | title | challengeType |
---|---|---|
587d8254367417b2b2512c71 | Remove items from a set in ES6 | 1 |
Description
delete
method.
First, create an ES6 Set
var set = new Set([1,2,3]);
Now remove an item from your Set with the delete
method.
set.delete(1);
console.log([...set]) // should return [ 2, 3 ]
Instructions
Tests
tests:
- text: Your Set should contain the values 1, 3, & 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
function checkSet(){
var set = new Set([1,2,3,4,5]);
set.delete(2);
set.delete(5);
return set;}