23
计算字符串中的单词
我试图以此方式对文本中的单词进行计数: function WordCount(str) { var totalSoFar = 0; for (var i = 0; i < WordCount.length; i++) if (str(i) === " ") { // if a space is found in str totalSoFar = +1; // add 1 to total so far } totalsoFar += 1; // add 1 to totalsoFar …
91
javascript