Created
January 5, 2021 15:42
-
-
Save Jagathishrex/e380462b2b527a464013ee58b15cce10 to your computer and use it in GitHub Desktop.
This file contains 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 hasDuplicates(array) { | |
let uniqueValues = new Set(array); // set --> contains only unique values | |
return uniqueValues.size !== array.length; | |
} | |
hasDupicates([1,2,3]); // false | |
hasDupicates([1,2,3,1]); // true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment