[JavaScript] Checking if a letter is alphabetic without Regex
We return whether or not the upper case version of a character is equal to the lower case version of a character.
If the character was a space or a punctuation symbol such as a comma or period, this function would have returned true because toUppercase() and toLowerCase() has no effect
on these specific characters. This implies that the character we are checking is not alphabetic.
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
var checkLetter = (c) => { | |
return c.toUpperCase() != c.toLowerCase(); | |
}; |
Comments
Post a Comment