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> words
</p>

JavaScript

"use strict";
console.clear();

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



myWordsToCount.addEventListener(onkeyup) = function(){

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

console.log(words);
});