diff --git a/snippets/isUpperCase.md b/snippets/isUpperCase.md index 3d4c74760..116241fc2 100644 --- a/snippets/isUpperCase.md +++ b/snippets/isUpperCase.md @@ -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 ```