Last active
August 13, 2017 21:52
-
-
Save alex-cory/93248b76f220b245d7464ab11c273c8a to your computer and use it in GitHub Desktop.
isAllUpperCase(word) isAllLowerCase(word) isCapitalizedOnly(word)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const isAllUp = s => s.match(/[^a-z]*/)[0].length === s.length | |
const isAllLow = s => s.match(/[a-z]*/)[0].length === s.length | |
const isCapitalized = s => s.substring(1, s.length).match(/[a-z]*/)[0].length === s.length - 1 && /^[A-Z]/.test(s) | |
console.log('All UP? expect: true got -> ', isAllUp('SOMEWORD')) | |
console.log('All UP? expect: false got -> ', isAllUp('Someword')) | |
console.log('All UP? expect: false got -> ', isAllUp('someword')) | |
console.log('All LOW? expect: true got -> ', isAllLow('someword')) | |
console.log('All LOW? expect: false got -> ', isAllLow('Someword')) | |
console.log('All LOW? expect: false got -> ', isAllLow('SOMEWORD')) | |
console.log('Capitalized? expect: true got -> ', isCapitalized('Someword')) | |
console.log('Capitalized? expect: false got -> ', isCapitalized('SOMEWORD')) | |
console.log('Capitalized? expect: false got -> ', isCapitalized('someword')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment