JSFiddle - React, Tailwind, and code Playground
by shivaay123
JavaScript
function getWordCount(str) {
return str.trim().split(/\s+/).length;
}
const sent = 'Hey how are you doing in upwork?';
console.log('Complete Sentence: '+sent);
console.log('Total words: '+getWordCount(sent));