Skip to content

Commit 83bd715

Browse files
authored
Merge pull request #56 from Akharote1/patch-1
2 parents 8243884 + da0f3d5 commit 83bd715

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

strings/anagram.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
//Check if 2 words are anagrams of each other.
2+
var o1 = "arms";
3+
var o2 = "mars"
4+
//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;
8+
if(isAnagram) console.log("The two words are anagrams");
9+
else console.log("The two words are not anagrams");

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy