📜  js 字符串检查案例 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:04:31.210000             🧑  作者: Mango

代码示例1
//Some characters like numbers or punctuation also return true 
//when checked for lowercase/uppercase.
//The solve is the second part
//I found this to work very well for it:
function isLowerCase(str)
{
    return str == str.toLowerCase() && str != str.toUpperCase();
}
console.log(isLowerCase("a")); //expected true
console.log(isLowerCase("A")); //expected false
console.log(isLowerCase("Ü")); //expected false
console.log(isLowerCase("4")); //expected false
console.log(isLowerCase("_")); //expected false