

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How can I check if a string is all uppercase in JavaScript?
You can compare the string against itself in upper case to check if it is in the upper case.
Example
function isUpperCase(str) { return str === str.toUpperCase(); } console.log(isUpperCase('a')) console.log(isUpperCase('A')) console.log(isUpperCase('ASDF 123 asd')) console.log(isUpperCase('TEST 123 TEST'))
Output
This will give the output −
false true false true
- Related Questions & Answers
- How can I check if a JavaScript function is defined?
- How can I check if a JavaScript variable is function type?
- Check if a string is sorted in JavaScript
- How to test if a letter in a string is uppercase or lowercase using javascript?
- How I can check if A is superclass of B in Python?
- Can I verify if a JavaScript variable is loaded if so, how?
- How can I check whether a variable is defined in JavaScript?
- Making a Java String All Uppercase or All Lowercase.
- Check if a string is repeating in itself in JavaScript
- How to check whether a string is in lowercase or uppercase in R?
- Check If a String Can Break Another String in C++
- JavaScript - Find if string is a palindrome (Check for punctuation)
- JavaScript: How to Check if a String is a Literal or an Object?
- How can I tell if a string repeats itself in Python?
- Replacing upperCase and LowerCase in a string - JavaScript
Advertisements