Skip to content

Commit 712128f

Browse files
Create distinctCount.js
1 parent c8da536 commit 712128f

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

Javascript/distinctCount.js

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
//Complete the function distinctCount() to return the number of distinct elements in the input array.
2+
3+
function distinctCount(array) {
4+
const myset = new Set()
5+
for(const num of array){
6+
myset.add(num)
7+
}
8+
return myset.size
9+
}
10+
11+
module.exports = distinctCount;

0 commit comments

Comments
 (0)