Earn extra honor and gain new allies!
Honor is earned for each new codewarrior who joins.
Learn more
Code
Diff
  • function wordCount(str) {
      return (str.match(/\b(?:\s+\b|\s*$)/g) || []).length;
    }
  • 11
    function wordCount(str) {
    
    2
      return str.replace(/\s/g, '').length ? str.trim().split(/\s+/).length : 0;
    
    2+
      return (str.match(/\b(?:\s+\b|\s*$)/g) || []).length;
    
    33
    }