8000
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent fcb8736 commit da0f3d5Copy full SHA for da0f3d5
strings/anagram.js
@@ -1,7 +1,7 @@
1
//Check if 2 words are anagrams of each other.
2
var o1 = "arms";
3
var o2 = "mars"
4
-//Remove
+//Remove non-letter characters, and sort the letters in alphabetical order.
5
var n1 = o1.replace(/\W+/g,'').toLowerCase().split("").sort().join("");
6
var n2 = o2.replace(/\W+/g,'').toLowerCase().split("").sort().join("");
7
var isAnagram = n1==n2;
0 commit comments