Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

anagram js

function isAnagram(stringA, stringB) {
  // Sanitizing
  stringA = stringA.toLowerCase().replace(/[W_]+/g, "");
  stringB = stringB.toLowerCase().replace(/[W_]+/g, "");

  // sorting
  const stringASorted = stringA.split("").sort().join("");
  const stringBSorted = stringB.split("").sort().join("");

  return stringASorted === stringBSorted;
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #anagram #js
ADD COMMENT
Topic
Name
3+4 =