30-seconds-of-code
Version:
A collection of useful JavaScript snippets.
17 lines (11 loc) • 316 B
Markdown
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 = str => str === str.toUpperCase();
```
```js
isUpperCase('ABC'); // true
isLowerCase('A3@$'); // true
isLowerCase('aB4'); // false
```