JSFiddle - React, Tailwind, and code Playground
HTML
<textarea></textarea>
<p></p>
JavaScript
$(function() {
$("textarea").keypress(function() {
total_words = this.value.split(/[\s\.\?]+/).length;
$("p").html(500 - total_words);
});
});