Überprüfen Sie, ob ein Buchstaben im Großbuchstaben JavaScript ist
const isUpperCase = (string) => /^[A-Z]*$/.test(string)
ammer
const isUpperCase = (string) => /^[A-Z]*$/.test(string)
function isUpper(str) {
return !/[a-z]/.test(str) && /[A-Z]/.test(str);
}
isUpper("FOO"); //true
isUpper("bar"); //false
isUpper("123"); //false
isUpper("123a"); //false
isUpper("123A"); //true
isUpper("A123"); //true
isUpper(""); //false
function hasLowerCase(str) {
return (/[a-z]/.test(str));
}
var word = 'apple' //Expected: false
//Use word[0] to grap the first letter
if (word[0] == word[0].toUpperCase()) {
//Word is uppercase
} else {
//Word is not uppercase
}
var strings = 'this iS a TeSt 523 Now!';
var i=0;
var character='';
while (i <= strings.length){
character = strings.charAt(i);
if (!isNaN(character * 1)){
alert('character is numeric');
}else{
if (character == character.toUpperCase()) {
alert ('upper case true');
}
if (character == character.toLowerCase()){
alert ('lower case true');
}
}
i++;
}
function startsWithCapital(word){
return word.charAt(0) === word.charAt(0).toUpperCase()
}