Created
July 8, 2016 01:16
-
-
Save craveytrain/9e874150d4c24ef624bb621fb96400fc to your computer and use it in GitHub Desktop.
Is first character in string upper case
This file contains 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 assert = require( 'assert' ); | |
/** | |
* Checks if first letter in string is upper case or lower case | |
* | |
* @param {string} str - string to test | |
* @returns {boolean} Returns bool of whether or not the string starts with upper case | |
* | |
* @example | |
* // returns true | |
* isFirstLetterUpperCase( 'Stuff' ); | |
* | |
*/ | |
function isFirstLetterUpperCase ( str ) { | |
assert( typeof str === 'string', 'Must supply a string'); | |
return /^[A-Z]/.test( str ); | |
} | |
module.exports = isFirstLetterUpperCase; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment