JSFiddle - React, Tailwind, and code Playground

by shivaay123

JavaScript

function getWordCount(str) {
    return str.split(' ')
      .filter(function(n) { return n != '' })
      .length;
}

const sent = 'Hey how are you doing in upwork?';
console.log('Complete Sentence: '+sent);
console.log('Total words: '+getWordCount(sent));