09. Quiz: Using Sets
Directions:
Create a variable with the name myFavoriteFlavors and give it the value of an empty Set 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:
Start Quiz:
/*
* 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.
*/
User's Answer:
(Note: The answer done by the user is not guaranteed to be correct)
/*
* 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);