diff --git a/01-js/easy/anagram.js b/01-js/easy/anagram.js index 8184c83083..4e5e91cb19 100644 --- a/01-js/easy/anagram.js +++ b/01-js/easy/anagram.js @@ -5,7 +5,20 @@ */ function isAnagram(str1, str2) { - -} +// both string are alredy defined in function so we have to sort these strings + str1=sortString(str1.tolowercase()); // decalred a function to sort characters of strings + str2=sortString(str2.tolowercase()); + if(str1==str2){ + return true; + } + else{ + return false; + } +function sortString(str){ + let charArray=str.split(''); // split function splits all characters in form of array + charArray.sort();// noe array of characters has been sorted + let ans=charArray.join(''); // all chracters rejoined to form new string + retrun ans; +} module.exports = isAnagram;