JSFiddle - React, Tailwind, and code Playground

by Jordan Marechal

HTML

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

<span id ="WordCount">0</span> words

JavaScript

"use strict";
console.clear();



var wordCount = document.getElementById("wordCount");
var myTextareaElement = document.getElementById("myWordsToCount");
var words = 0;
for (var i = 0; i < len; i++) {

currentIndex++; 

words += wordCount[i];
}


myTextareaElement.onkeyup = function() {
var words = myWordsToCount.value.split(' ');

function wordCount(str) {
return str.split(' ').length;
 document.getElementById("wordCount").innerHTML = words;
}
}
//varmywordsToCount.addEventListener("keyup",function() {
//myTextareaElement.value = ' ';
//console.log wordCount(' ');
//}

////wordCount.innerText = words.length;
 //
//




  
//
//



//