isUpperCase

This commit is contained in:
Rohit Tanwar
2018-01-06 14:46:05 +05:30
parent 2bc04c38f0
commit 7fb18e9fc6
2 changed files with 33 additions and 0 deletions

16
snippets/isUpperCase.md Normal file
View File

@ -0,0 +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.
``` js
const isUpperCase = (val,symbol = false) => {
if (symbol) return val === val.toUpperCase()
else return!(/[^A-Z]/g.test(val))
}
```
``` js
isUpperCase('ABC'); //true
isUpperCase('ABC123@$'); //false
isUpperCase('ABC123@$',true); //true
isUpperCase('ABC123@$abcd',true); //false
isUpperCase('ABC123@$abcd'); //false
```