Skip to content

Instantly share code, notes, and snippets.

@craveytrain
Created July 8, 2016 01:16
Show Gist options
  • Save craveytrain/9e874150d4c24ef624bb621fb96400fc to your computer and use it in GitHub Desktop.
Save craveytrain/9e874150d4c24ef624bb621fb96400fc to your computer and use it in GitHub Desktop.
Is first character in string upper case
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