Skip to content

Instantly share code, notes, and snippets.

@Jagathishrex
Created January 5, 2021 15:42
Show Gist options
  • Save Jagathishrex/e380462b2b527a464013ee58b15cce10 to your computer and use it in GitHub Desktop.
Save Jagathishrex/e380462b2b527a464013ee58b15cce10 to your computer and use it in GitHub Desktop.
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