Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
44
rated 0 times [  51] [ 7]  / answers: 1 / hits: 77893  / 11 Years ago, wed, july 10, 2013, 12:00:00

There is a Javascript/Jquery boolean function to test if a string is all uppercase?



example of matching:



hello => false
Hello => false
HELLO => true

More From » string

 Answers
8
function isUpperCase(str) {
return str === str.toUpperCase();
}


isUpperCase(hello); // false
isUpperCase(Hello); // false
isUpperCase(HELLO); // true


You could also augment String.prototype:



String.prototype.isUpperCase = function() {
return this.valueOf().toUpperCase() === this.valueOf();
};


Hello.isUpperCase(); // false
HELLO.isUpperCase(); // true

[#77090] Tuesday, July 9, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
kristinsonjab

Total Points: 364
Total Questions: 98
Total Answers: 98

Location: Christmas Island
Member since Mon, Oct 19, 2020
4 Years ago
kristinsonjab questions
Fri, Mar 4, 22, 00:00, 2 Years ago
Fri, Jan 22, 21, 00:00, 3 Years ago
Fri, Aug 14, 20, 00:00, 4 Years ago
;