Created
October 3, 2017 20:59
-
-
Save unilecs/40e43789eb9c3106c1b3fb3c85d84262 to your computer and use it in GitHub Desktop.
Check that all symbols are unique in the string
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 checkUniqueSymbols(inputStr) { | |
if (inputStr) { | |
const hasDuplicateSymbols = inputStr.match(/(\w)(.+)?\1/) !== null; | |
return !hasDuplicateSymbols; | |
} | |
return false; | |
} | |
console.info("abcadez", checkUniqueSymbols("abcadez")); // false | |
console.info("abcdefg", checkUniqueSymbols("abcdefg")); // true | |
console.info(" try ", checkUniqueSymbols(" try ")); // true | |
console.info(" ", checkUniqueSymbols(" ")); // true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment