function isAnagram(a, b) {
const sort = s => s.split('').sort().join('');
return sort(a) === sort(b);
}
isAnagram('listen', 'silent'); // trueCheck if two strings are anagrams by sorting their characters and comparing.
Two strings are anagrams if they contain the same characters in a different order (ignoring case and spaces).
"listen" and "silent" are anagrams
"hello" and "world" are not anagrams
Algorithm:
function isAnagram(str1: string, str2: string): boolean {
// Return true if str1 and str2 are anagrams
}
isAnagram('listen', 'silent') // true