how to make anagrams of words in javascript code example

Example 1: javascript anagram check

const areAnagram = (str1, str2) => str1.toLowerCase().split('').sort().join('') === str2.toLowerCase().split('').sort().join('');

// Examples
areAnagram('listen', 'silent');         // true
areAnagram('they see', 'the eyes');     // true
areAnagram('node', 'deno');             // true

Example 2: anagram javascript example

function anagram(name, words) {
	var a = name.replace(/\s/g,'').toLowerCase().split('').sort().join('');
	var b = words.join('').split('').sort().join('');
	return a == b;
}

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