Created
September 6, 2019 04:55
-
-
Save masautt/2ec67e0cd0c580a6336034a99f46ed6a to your computer and use it in GitHub Desktop.
How to check if 2 strings are anagrams in JavaScript?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function isAnagram (a, b) { | |
var y = a.split("").sort().join(""), | |
z = b.split("").sort().join(""); | |
return (z === y) | |
} | |
console.log(isAnagram("marek", "kemra")) // --> true | |
console.log(isAnagram("sautter", "sautrra")) // --> false | |
// https://stackoverflow.com/questions/23785465/javascript-anagram-comparison |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment