Remove items from a set in ES6

What is your hint or solution suggestion?
On previous challenge we had to add items and i’ve done like:




And it worked and i’ve past the challenge, but now with delete method this seems not to work:


instead i need to use the ‘set’ every time .



Challenge: Remove items from a set in ES6

Link to the challenge:

are you asking a question, or want to contribute to the guide? I don’t understand

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (’).

Ohh! My bad! Now that looks much better :slight_smile: I can see … at least I’ve learned another thing, Thanks!

I’m just confused , and yes I’m asking a question more than I try to contribute probably.

Basically why the ‘.add’ method worked differently than the ‘.delete’ one?
Cheers! :slight_smile:

Hey @danutzz888,

The .delete method for a set will return a true or false. Here’s more about it:

That means you cannot chain methods together. So this:

set.delete(item) // returns true
   .delete(item) // this will make an error because true doesn't have a delete attribute it's just a boolean.

While the .add method returns the NEW set with the added value into it.
Here’s an mdn about it:

Hope this helps you understand a little bit…

Tip: This will always apply when you are trying to chain methods. Always check what the method returns before trying to chain a lot of methods at once. Or just not chain it and call it again.

1 Like

Aha, cool ! now that made some light!

I’m going thru that in a minute !

Cheers! :slight_smile:

1 Like