Files
30-seconds-of-code/snippets/isLowerCase.md
Rohit Tanwar 9eafe94ed7 isLowerCase
2018-01-06 14:46:39 +05:30

539 B

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.

const isLowerCase = (val,symbol = false) => {
  if (symbol) return val === val.toLowerCase()
  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