← All tasksJavaScript · Junior

isAnagram: anagrams

Write a function isAnagram(a, b) that checks whether two strings consist of the same letters in the same quantities.

Ignore case and spaces: "Dormitory" and "dirty room" are anagrams.

Tests (6)

  1. expect(isAnagram("listen", "silent")).toBe(true);
  2. expect(isAnagram("Dormitory", "dirty room")).toBe(true);
  3. expect(isAnagram("hello", "world")).toBe(false);
  4. expect(isAnagram("aab", "abb")).toBe(false);
  5. expect(isAnagram("abc", "abcd")).toBe(false);
  6. expect(isAnagram("", "")).toBe(true);