Ad
Code
Diff
  • function wordCount(str) {
      return (str.match(/\b(?:\s+\b|\s*$)/g) || []).length;
    }
    • function wordCount(str) {
    • return str.replace(/\s/g, '').length ? str.trim().split(/\s+/).length : 0;
    • return (str.match(/\b(?:\s+\b|\s*$)/g) || []).length;
    • }