lib/rules/new-cap.js
function getCap(str) {
            const firstChar = str.charAt(0);

            const firstCharLower = firstChar.toLowerCase();
            const firstCharUpper = firstChar.toUpperCase();

            if (firstCharLower === firstCharUpper) {

                // char has no uppercase variant, so it's non-alphabetic
                return "non-alpha";
            }
            if (firstChar === firstCharLower) {
                return "lower";
            }
            return "upper";

        }
function getCap(str) {
            const firstChar = str.charAt(0);

            const firstCharLower = firstChar.toLowerCase();
            const firstCharUpper = firstChar.toUpperCase();

            if (firstCharLower === firstCharUpper) {

                // char has no uppercase variant, so it's non-alphabetic
                return "non-alpha";
            }
            if (firstChar === firstCharLower) {
                return "lower";
            }
            return "upper";

        }
function getCap ( str ) { const firstChar = str . charAt ( 0 ) ; const firstCharLower = firstChar . toLowerCase ( ) ; const firstCharUpper = firstChar . toUpperCase ( ) ; if ( firstCharLower === firstCharUpper ) { // char has no uppercase variant, so it's non-alphabetic return "non-alpha" ; } if ( firstChar === firstCharLower ) { return "lower" ; } return "upper" ; }
Returns the capitalization state of the string -
Whether the first character is uppercase, lowercase, or non-alphabetic
@param {string} str String
@returns {string} capitalization state: "non-alpha", "lower", or "upper"
Returns the capitalization state of the string - Whether the first character is uppercase lowercase or non - alphabetic