Quiz: Using Sets
Directions:
Create a variable with the namemyFavoriteFlavors
and give it the value of an emptySet
object. Then use the.add()
method to add the following strings to it:
- "chocolate chip"
- "cookies and cream"
- "strawberry"
- "vanilla"
Then use the.delete()
method to remove "strawberry" from the set.
Your Code:
/*
* Programming Quiz: Using Sets (3-1)
*
* Create a Set object and store it in a variable named `myFavoriteFlavors`. Add the following strings to the set:
* - chocolate chip
* - cookies and cream
* - strawberry
* - vanilla
*
* Then use the `.delete()` method to remove "strawberry" from the set.
*/
const myFavoriteFlavors = new Set();
myFavoriteFlavors.add('chocolate chip');
myFavoriteFlavors.add('cookies and cream');
myFavoriteFlavors.add('strawberry');
myFavoriteFlavors.add('vanilla');
myFavoriteFlavors.delete('strawberry');
console.log(myFavoriteFlavors);