1-line JavaScript solution, no regex


  • 2
    var detectCapitalUse = function(word) {
        return word === word.toUpperCase() || word === word[0] + word.substr(1).toLowerCase();
    };
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.