Update isUpperCase.md
This commit is contained in:
@ -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
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user