538 B
538 B
isUpperCase
Checks if the provided argument contains anything else than the uppercase alphabets. If the second argument is provided to be true than numbers and other symbols are considered uppercase too.
const isUpperCase = (val,symbol = false) => {
if (symbol) return val === val.toUpperCase()
else return!(/[^A-Z]/g.test(val))
}
isUpperCase('ABC'); //true
isUpperCase('ABC123@$'); //false
isUpperCase('ABC123@$',true); //true
isUpperCase('ABC123@$abcd',true); //false
isUpperCase('ABC123@$abcd'); //false