Answers for "how to check string anagrams"

1

check if two strings are anagrams python

if sorted(s1) == sorted(s2): 
	print("The strings are anagrams.") 
else: 
	print("The strings aren't anagrams.")
Posted by: Guest on April-07-2020
0

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;
}
Posted by: Guest on June-19-2020

Code answers related to "how to check string anagrams"

Code answers related to "Javascript"

Browse Popular Code Answers by Language