Created
August 15, 2020 14:13
-
-
Save noximus/0623cea0c39b4b6d32b62367ad365a61 to your computer and use it in GitHub Desktop.
This is to show how to make a simple String Prototype for an anagram.
This file contains 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
String.prototype.sortLetters = function() { | |
return this.toLowerCase().split('').sort().join(''); | |
} | |
var isAnagram = function(test, original) { | |
return test.sortLetters() == original.sortLetters(); | |
}; | |
// This is to show how to make a simple String Prototype for an anagram. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment