Last active
June 11, 2025 03:47
-
-
Save orrisroot/e32a9358c53324c217875af5353f972e to your computer and use it in GitHub Desktop.
Whether an array has duplicate elements
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
| const hasDuplicate = <T,>(items: T[], func: (a: T, b: T) => boolean = (a, b) => a === b): boolean => { | |
| return items.find((item, idx) => items.some((item2, idx2) => func(item, item2) && idx !== idx2)) != null; | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment