javascript algorithm for detecting anagram in a string code example
Example 1: javascript anagram check
const areAnagram = (str1, str2) => str1.toLowerCase().split('').sort().join('') === str2.toLowerCase().split('').sort().join('');
areAnagram('listen', 'silent');
areAnagram('they see', 'the eyes');
areAnagram('node', 'deno');
Example 2: anagram javascript example
function anagram(name, words) {
name = name.toLowerCase().split('').sort().join('').trim();
words = words.join('').toLowerCase().split('').sort().join('');
return name === words;
}