I am extracting a character in a Javascript string with:
var first = str.charAt(0);
and I would like to check whether it is a letter. Stran
I made a function to do this:
var isLetter = function (character) {
if( (character.charCodeAt() >= 65 && character.charCodeAt() <= 90) || (character.charCodeAt() >= 97 && character.charCodeAt() <= 122) ) {
return true;
}
else{
return false;
}
}
This basically verifies in the ASCII table if the code of the character refers to a Letter.
You can see the ASCII table on this link and compare columns DEC (where is the code) and symbol: https://www.ascii-code.com/
Note: My function is true only to "simple" letters (things like "Á", "é", "ç", "Ü" it will return false... but if you needed you can adapt this function to de other conditions).