Check if two phrases are anagrams, ignoring case and symbols
A word-game app lets players submit an anagram of the daily phrase. Players type naturally, with spaces, capital letters, and punctuation, so the check has to look past all of that. Implement isAnagramPhrase(first, second), which returns true when second is a real rearrangement of first.
isAnagramPhrase(first, second) // => boolean
a–z and A–Z, and the digits 0–9. Every other character (spaces, punctuation, emoji, accented letters such as é) is ignored.'A' and 'a' are the same character.true when both phrases contain exactly the same counted characters, each the same number of times, and the order differs.'Listen!' and 'listen'), the player only retyped the phrase: return false.false.isAnagramPhrase('Dormitory', 'Dirty room!'); // => true
isAnagramPhrase('Astronomer', 'Moon starer'); // => true
isAnagramPhrase('Room 101', '110 moor'); // => true (digits count)
isAnagramPhrase('Room 101', 'Room 11'); // => false (one 0 is missing)
isAnagramPhrase('aab', 'abb'); // => false (different counts)
isAnagramPhrase('Listen', 'listen!'); // => false (same order)
isAnagramPhrase('naïve', 'vane'); // => true ('ï' is ignored)
isAnagramPhrase('?!', '...'); // => false (nothing to compare)