if (character == character.toLowerCase())
{
// The character is lowercase
}
else
{
// The character is uppercase
}
//The problem with this answer is,
//that some characters like numbers or punctuation
//also return true when checked for lowercase/uppercase.
// this is the solution for it:
function isLowerCase(str)
{
return str == str.toLowerCase() && str != str.toUpperCase();
}
// A minified version of the other one:
const hasLowerCase= s => s.toUpperCase() != s;
console.log("HeLLO: ", hasLowerCase("HeLLO"));
console.log("HELLO: ", hasLowerCase("HELLO"));
function hasLowerCase(str) {
return str.toUpperCase() != str;
}
console.log("HeLLO: ", hasLowerCase("HeLLO"));
console.log("HELLO: ", hasLowerCase("HELLO"));