JSFiddle - React, Tailwind, and code Playground

by Jordan Marechal

HTML

<p>
<textarea id="myWordsToCount" rows="5" cols="60"></textarea>
</p>

<p>
<span id ="wordCount">0</span> totalwords
</p>

JavaScript

"use strict";
console.clear();

var myWordsToCount = document.getElementById("myWordsToCount");
var wordCount = document.getElementById("wordCount");



myWordsToCount.addEventListener ("keyup", function() {

var totalwords = myWordsToCount.value.split(' ');// using the string split
wordCount.innerText = totalwords.length;

console.log(totalwords);
});