Strings

Valid Anagram

Valid Anagram

Two words are anagrams when they use the same characters the same number of times, just in a different order. A useful checker should compare the character makeup, not the original order.

Your task: Write isAnagram. It should trim outside whitespace, ignore letter casing, and return whether the two strings are anagrams.

Prerequisites

  • functions
  • strings
  • objects
  • loops
  • conditionals

Tests

  • returns true for two lowercase anagrams
  • normalizes casing and outside whitespace
  • returns false when the strings have different lengths
  • returns false when one character count is different
  • handles empty strings as matching anagrams
Loading...
Console

Run code to see output.