String is lowercase

OSCC · JavaScript, String · Oct 20, 2020

Checks if a string is lower case.

  • Convert the given string to lower case, using String.prototype.toLowerCase() and compare it to the original.
const isLowerCase = str => str === str.toLowerCase();
isLowerCase('abc'); // true
isLowerCase('a3@$'); // true
isLowerCase('Ab4'); // false

Recommended snippets

  • Swapcase string

    JavaScript, String

    Creates a string with uppercase characters converted to lowercase and vice versa.

  • String is anagram

    JavaScript, String

    Checks if a string is an anagram of another string (case-insensitive, ignores spaces, punctuation and special characters).

  • String is uppercase

    JavaScript, String

    Checks if a string is upper case.