Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

check if anagram

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 www.kdnuggets.com #
 
PREVIOUS NEXT
Tagged: #check #anagram
ADD COMMENT
Topic
Name
5+4 =