2.8 KiB
2.8 KiB
title
| title |
|---|
| Size of the Set |
Size of the Set
Remember to use Read-Search-Ask 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;
}
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.

See
![]()
Wiki Challenge Solution Templatefor reference.


