Intuitive Javascript Solution


  • 5
    D
    var detectCapitalUse = function(word) {
        // either all capitals, all small cases, or Capital follow by small cases
        return /^[A-Z]+$|^[a-z]+$|^[A-Z][a-z]+$/.test(word);
    };
    

Log in to reply
 

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