Trusted answers to developer questions

How to check if a character is lowercase in Javascript

Free System Design Interview Course

Many candidates are rejected or down-leveled due to poor performance in their System Design Interview. Stand out in System Design Interviews and get hired in 2024 with this popular free course.

Characters hold ASCIIAmerican Standard Code for Information Interchange codes. ASCII was developed as a standard character set for computers and electronic devices.

These codes or numbers can also be called character codes or their equivalent number.

Using event.charCode

In Javascript, event.charCode, which is a property of the keyboard event keypress, prints the character code of any character on the keyboard.

Code

The example below reveals the charCode of any character entered in the input box below. The keypress event is used to determine the character pressed.

charCode range of lowecase characters

Alphabets have their charCode values in a particular range. Lowercase alphabets fall within the range of 97 - 122.


The trick to determine if a character is lowercase lies in knowing its value in the range 97 - 122.

How to check if a character is lowercase

Explanation

From the code above, we can see that any charChode that falls outside the range of 97 - 122 is not lowercase.

RELATED TAGS

javascript
character
lowercase

CONTRIBUTOR

Theodore Kelechukwu Onyejiaku
Did you find this helpful?