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