Ad
Code
Diff
  • function wordCount(str) {
      return str.split(' ').filter((w) => w.length).length
    }
    • function wordCount(str) {
    • var words = 0;
    • str.split(' ').forEach(function (w) {if (w.length) words++});
    • return words;
    • return str.split(' ').filter((w) => w.length).length
    • }