js check if string contains uppercase code example
Example 1: check if letter is uppercase javascript
const isUpperCase = (string) => /^[A-Z]*$/.test(string)
Example 2: regex for lowercase letters js
function hasLowerCase(str) {
return (/[a-z]/.test(str));
}
Example 3: how to check string uppercase or lowersace using regex javascript
var regex = /^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[!#\*\?])(?=.{8,})/;
Example 4: check if letter is uppercase javascript
isUpperCase('A')
isUpperCase('a')
Example 5: how to check if the first letter of a string is capitalized or uppercase in js
function startsWithCapital(word){
return word.charAt(0) === word.charAt(0).toUpperCase()
}
console.log(startsWithCapital("Hello"))
console.log(startsWithCapital("hello"))