Write a program to check two String are anagram or not.
Anagram Strings: Two strings are said to be anagram if the frequency of each character in both the strings is the same.
Example:
Input: a="Army", b="Mary"
Output: Strings are Anagram
Approach
JavaScript
var firstWord = "Mary";var secondWord = "Army";var a = firstWord.toLowerCase();var b = secondWord.toLowerCase();a = a.split("").sort().join("");b = b.split("").sort().join("");if (a === b) {console.log("Given string are anagram");}else {console.log("Given string are not anagram");}
No comments:
Post a Comment