Created
March 29, 2021 20:45
-
-
Save ipekt/bf32b30db6f8ccef3d45a9bfedbd3a1b to your computer and use it in GitHub Desktop.
Frequency Counter 2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function areThereDuplicates(...values) { | |
| let counter = {}; | |
| for(let i=0; i<values.length; i++) { | |
| if (counter[values[i]] === undefined) { | |
| counter[values[i]] += 1; | |
| } else { | |
| return true; | |
| } | |
| } | |
| return false; | |
| } | |
| areThereDuplicates(1,2,3,2); // true | |
| areThereDuplicates(1,2,3); // false |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment