← 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.
Ctrl+Enter runs the tests. Tab indents; to leave the editor with the keyboard, press Esc and then Tab. Your code is saved in this browser.
Tests (6)
expect(isAnagram("listen", "silent")).toBe(true);
expect(isAnagram("Dormitory", "dirty room")).toBe(true);
expect(isAnagram("hello", "world")).toBe(false);
expect(isAnagram("aab", "abb")).toBe(false);
expect(isAnagram("abc", "abcd")).toBe(false);
expect(isAnagram("", "")).toBe(true);