Created
September 20, 2018 15:38
-
-
Save spektraldevelopment/c918d3e57e789460106ce3beb1a177a4 to your computer and use it in GitHub Desktop.
JS: Anagrams
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 anagrams(stringA, stringB) { | |
return cleanString(stringA) === cleanString(stringB) | |
} | |
function cleanString(str) { | |
return str.replace(/[^\w]/g, "").toLowerCase().split("").sort().join(""); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment