JavaScript - checking for any lowercase letters in a string
function hasLowerCase(str) {
return str.toUpperCase() != str;
}
console.log("HeLLO: ", hasLowerCase("HeLLO"));
console.log("HELLO: ", hasLowerCase("HELLO"));
Another solution only match regex to a-z
function nameHere(str) {
return str.match(/[a-z]/);
}
or
function nameHere(str) {
return /[a-z]/g.test(str);
}
function hasLowerCase(str) {
return str.toUpperCase() != str;
}
or
function hasLowerCase(str) {
for(x=0;x<str.length;x++)
if(str.charAt(x) >= 'a' && str.charAt(x) <= 'z')
return true;
return false;
}
also:
function hasLowerCase(str) {
return (/[a-z]/.test(str));
}