Skip to content

Instantly share code, notes, and snippets.

@belide
Created June 26, 2017 10:18
Show Gist options
  • Save belide/7c7e458e893a3815fba146cd6b11cfd0 to your computer and use it in GitHub Desktop.
Save belide/7c7e458e893a3815fba146cd6b11cfd0 to your computer and use it in GitHub Desktop.
function anagrams(a,b){
var count = 0, isAnagram=false;
var a1 = a.split("").sort();
var b1 = b.split("").sort();
for(var i=0;i<a1.length;i++){
if(a1[i] !== b1[i]){
count++;
}
}
if(count===0){
console.log("is Anagram");
}
else{
console.log("not Anagram diff is", count);
}
}
anagrams("eedbaasab","aabccddaa");
anagrams("aabccddaa","aabccddaa");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment