function wordCount(str) { return str.trim().split(" ").length; }
function wordCount(str) {var words = 1;for(var i = 1; i < str.length; i++) {if(str[i] == " " && str[i - 1] !== " "&& str[i + 1] !== " ") {words++;}}return words;- function wordCount(str) {
- return str.trim().split(" ").length;
- }