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 4e3ae65 commit fcb8736Copy full SHA for fcb8736
strings/anagram.js
@@ -0,0 +1,9 @@
1
+//Check if 2 words are anagrams of each other.
2
+var o1 = "arms";
3
+var o2 = "mars"
4
+//Remove
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;
8
+if(isAnagram) console.log("The two words are anagrams");
9
+else console.log("The two words are not anagrams");
0 commit comments