fix: removed guide articles no longer needed (#35679)
This commit is contained in:
@ -1,55 +0,0 @@
|
|||||||
---
|
|
||||||
title: Remove from a Set
|
|
||||||
---
|
|
||||||
## Remove from a Set
|
|
||||||
 Remember to use <a>**`Read-Search-Ask`**</a> if you get stuck. Try to pair program  and write your own code 
|
|
||||||
|
|
||||||
###  Problem Explanation:
|
|
||||||
|
|
||||||
To solve this problem, you have to write a function for the class that removes a given element from the array if the array contains the given element.
|
|
||||||
|
|
||||||
|
|
||||||
##  Hint: 1
|
|
||||||
|
|
||||||
|
|
||||||
Use the built-in "has" function already created to test if the element exists in the Set.
|
|
||||||
|
|
||||||
> _try to solve the problem now_
|
|
||||||
|
|
||||||
##  Hint: 2
|
|
||||||
|
|
||||||
Use the splice function to delete an element from an array.
|
|
||||||
|
|
||||||
> _try to solve the problem now_
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Spoiler Alert!
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
**Solution ahead!**
|
|
||||||
|
|
||||||
##  Basic Code Solution:
|
|
||||||
|
|
||||||
this.remove = function(element){
|
|
||||||
if(this.has(element)) {
|
|
||||||
this.values().splice( this.values().indexOf(element), 1 );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
 <a href='https://repl.it/repls/ReflectingUsedTrees' target='_blank' rel='nofollow'>Run Code</a>
|
|
||||||
|
|
||||||
### Code Explanation:
|
|
||||||
|
|
||||||
* The if statement checks if the collection contains the element.
|
|
||||||
* If the if statement evaluates to true, then starting from the index at which the element is located, one element is deleted.
|
|
||||||
* If the if statement evaluates to false, then nothing occurs.
|
|
||||||
|
|
||||||
##  NOTES FOR CONTRIBUTIONS:
|
|
||||||
|
|
||||||
 **DO NOT** add solutions that are similar to any existing solutions. If you think it is **_similar but better_**, then try to merge (or replace) the existing similar solution.
|
|
||||||
|
|
||||||
Add an explanation of your solution.
|
|
||||||
|
|
||||||
Categorize the solution in one of the following categories — **Basic**, **Intermediate** and **Advanced**. 
|
|
@ -1,49 +0,0 @@
|
|||||||
---
|
|
||||||
title: Size of the Set
|
|
||||||
---
|
|
||||||
## Size of the Set
|
|
||||||
 Remember to use <a>**`Read-Search-Ask`**</a> if you get stuck. Try to pair program  and write your own code 
|
|
||||||
|
|
||||||
###  Problem Explanation:
|
|
||||||
|
|
||||||
To solve this problem, you have to write a function for the class that returns the size of the set.
|
|
||||||
|
|
||||||
|
|
||||||
##  Hint: 1
|
|
||||||
|
|
||||||
Create a size function in the Set class.
|
|
||||||
|
|
||||||
> _try to solve the problem now_
|
|
||||||
|
|
||||||
##  Hint: 2
|
|
||||||
|
|
||||||
Use the length attribute on the values of the Set.
|
|
||||||
|
|
||||||
> _try to solve the problem now_
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Spoiler Alert!
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
**Solution ahead!**
|
|
||||||
|
|
||||||
##  Basic Code Solution:
|
|
||||||
|
|
||||||
this.size = function()
|
|
||||||
{
|
|
||||||
return this.values().length;
|
|
||||||
}
|
|
||||||
|
|
||||||
 <a href='https://repl.it/repls/SereneScholarlyAnalyst' target='_blank' rel='nofollow'>Run Code</a>
|
|
||||||
|
|
||||||
### Code Explanation:
|
|
||||||
|
|
||||||
* The number of items is achieved by attaining the collection using the "values" function and getting the length attribute of it.
|
|
||||||
|
|
||||||
##  NOTES FOR CONTRIBUTIONS:
|
|
||||||
|
|
||||||
*  **DO NOT** add solutions that are similar to any existing solutions. If you think it is **_similar but better_**, then try to merge (or replace) the existing similar solution.
|
|
||||||
* Add an explanation of your solution.
|
|
||||||
* Categorize the solution in one of the following categories — **Basic**, **Intermediate** and **Advanced**. 
|
|
Reference in New Issue
Block a user