Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Lines changed: 11 additions & 0 deletions
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)

AltStyle によって変換されたページ (->オリジナル) /