Skip to content

Commit e33acc3

Browse files
author
saurav
committed
added code to check anagram
1 parent 9dc6914 commit e33acc3

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

Strings/anagram.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
export default class Anagram {
2+
3+
static isAnagram(str1, str2) {
4+
if (str1.length !== str2.length) {
5+
// check if the length is same
6+
//{result:false,err:"LengthShouldBeSame"}
7+
return false
8+
} else {
9+
// ;
10+
return str1.split('').sort().join('') === str2.split('').sort().join('');
11+
}
12+
}
13+
}

0 commit comments

Comments
 (0)