December 2023
Intermediate to advanced
242 pages
5h 28m
English
| Recipe 17 | Determining Letter Case with charAt() |
Consider a scenario where you have a form that requests the user to enter their nickname. Some users may prefer to enter their nickname in lowercase letters, so your app shouldn’t automatically capitalize the nickname. But perhaps some users are casual about typing and intend for their name to be capitalized.
In such cases, you want to notify the user that their nickname will be stored and displayed exactly as entered. So, your app needs to be capable of identifying the letter case of the first character of the nickname.
Use the strict inequality operator (!==) to compare the first character (index 0) of the string to its lowercase version. If they are not equal, that means the string ...
Read now
Unlock full access