category | contributors | created | title | updated | |
---|---|---|---|---|---|
String |
|
2020-05-07 |
Check if two strings are anagram |
2021-10-13 |
JavaScript version
const areAnagram = (str1, str2) =>
str1.toLowerCase().split('').sort().join('') === str2.toLowerCase().split('').sort().join('');
TypeScript version
const areAnagram = (str1: string, str2: string): boolean =>
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