JSFiddle - React, Tailwind, and code Playground
HTML
<p>
<textarea id="myWordsToCount" rows="5" cols="60"></textarea>
</p>
<p>
<span id ="wordCount">0</span> words
</p>
JavaScript
"use strict";
console.clear();
var myWordsToCount = document.getElementById("myWordsToCount");
var wordCount = document.getElementById("wordCount");
myWordsToCount.addEventListener("keyup",function(){
var words = myWordsToCount.value.split(' ');
wordCount.innerText = words.length;
});