Skip to content

Instantly share code, notes, and snippets.

@spektraldevelopment
Created September 20, 2018 15:38
Show Gist options
  • Save spektraldevelopment/c918d3e57e789460106ce3beb1a177a4 to your computer and use it in GitHub Desktop.
Save spektraldevelopment/c918d3e57e789460106ce3beb1a177a4 to your computer and use it in GitHub Desktop.
JS: Anagrams
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