isUpperCase

This commit is contained in:
Rohit Tanwar
2018-01-06 14:46:05 +05:30
parent 9d9ada1642
commit 5b9b3cd4d4
2 changed files with 33 additions and 0 deletions

17
snippets/isLowerCase.md Normal file
View File

@ -0,0 +1,17 @@
### isLowerCase
Checks if the provided argument contains anything else than the lowerCase alphabets. If the second argument is provided to be true than numbers and other symbols are considered lowercase too.
``` js
const isLowerCase = (val,symbol = false) => {
if (symbol) return val === val.toLowerCase()
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
```