String is uppercase

OSCC · JavaScript, String · Sep 15, 2020

Checks if a string is upper case.

  • Convert the given string to upper case, using String.prototype.toUpperCase() and compare it to the original.
const isUpperCase = str => str === str.toUpperCase();
isUpperCase('ABC'); // true
isUpperCase('A3@$'); // true
isUpperCase('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 lowercase

    JavaScript, String

    Checks if a string is lower case.