if you want to check the given two words are blanagrams, step 1: you need to check the lengths of the given two words are exactly the same. step 2: you also need to check if they contain the same letters code example

Example: 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;
}