Update isUpperCase.md

This commit is contained in:
Angelos Chalaris
2018-01-06 13:53:42 +02:00
committed by GitHub
parent 0232fd890e
commit b20483fa8d

View File

@ -1,16 +1,16 @@
### 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.
Checks if a string is upper case.
Convert the given string to upper case, using `String.toUpperCase()` and compare it to the original.
``` js
const isUpperCase = (val,symbol = false) => {
if (symbol) return val === val.toUpperCase()
else return!(/[^A-Z]/g.test(val))
}
const isUpperCase = str => str === str.toUpperCase();
```
``` js
isUpperCase('ABC'); //true
isUpperCase('ABC123@$'); //false
isUpperCase('ABC123@$',true); //true
isUpperCase('ABC123@$abcd',true); //false
isUpperCase('ABC123@$abcd'); //false
isUpperCase('ABC'); // true
isLowerCase('A3@$'); // true
isLowerCase('aB4'); // false
```