JSFiddle - React, Tailwind, and code Playground

jQuery Text Statistics - letter count - word count - syllable count - list of words and how many times they appear - Automated Readability Index - Coleman Liau Index - Flesch Kincaid Reading Ease - Flesch Kincaid Grade Level

by chrisallenmoore

HTML

<h2>
    on keyup, loop over the textarea, put it into an array put it into an li and increment how many times the word is shown.
</h2>
<br />
<form name = "myform">
    <textarea name="msg" id="msg">The Dale-Chall Readability Formula was inspired by Rudolph Flesch's Flesch–Kincaid readability test which used word to determine how difficult a word was for readers to understand. Edgar Dale and Jeanne Chall instead used a list of 763 words that 80% of fourth-grade students were familiar with to determine which words were difficult. The Dale-Chall Readability Formula was originally published in their 1948 article A Formula for Predicting Readability[1] and updated in 1995 in Readability Revisited: The New Dale-Chall Readability Formula, which expanded the word list to 3,000 familiar words.</textarea>
</form>     
 
<br />
    <p>Character Count Total: <span id="characterCount"></span><p>
    <p>Word Count Total: <span id="wordCount"></span><p>
    <p>Sentence Count Total: <span id="sentenceCount"></span><p>
    <p>Syllable Count Total: <span id="syllableCount"></span></p>
    <br />
    <p>Average Characters per Word: <span id="avgCharactersPerWord"></span></p>
    <p>Average Syllables per Word: <span id="avgSyllablesPerWord"></span></p>
    <p>Average Characters per Sentence: <span id="avgCharactersPerSentence"></span></p>
    <p>Average Words per Sentence: <span id="avgWordsPerSentence"></span></p>
    <br />
    <p>Automated Readability Index: <span id="automatedReadabilityIndex"></span></p>
    <p>Coleman Liau Index: <span id="colemanLiauIndex"></span></p>
    <p>Flesch Kindcaid Reading Ease: <span id="fleschKincaidReadingEase"></span></p>
    <p>Flesch Kindcaid Grade Level: <span id="fleschKincaidGradeLevel"></span></p>
    <p>Gunning Fog Score: <span id="gunningFogScore"></span></p>
    <p>Smog Index: <span id="smogIndex"></span></p>
        <br />    
<p>
List of the words in your text &amp; the  number of times they show:
</p>    
<br />

<!---
This is the...

CSS

textarea {
    width: 90%;
    height: 200px;
}

span {
    color: blue;
    font-weight: normal;
}

p {
    font-weight: bold;
}

JavaScript

$("#msg").keyup(function() {
    // Get a refernce to the OL list element.
    var $jList = $("#list");    
    $jList.html("");
    
    // Create raw array from text in textarea
    var textString = $(this).val();
    
    // cleanup raw text array
    var cleanText = textString.replace(/[^a-zA-Z 0-9']+/g,' ').trim();
    cleanText = cleanText.replace(/\s+/g,' ');
    
    // rough syllable count
    var syllableCount = cleanText.split(/.[aeiouy]+/i).length;
    
    // create character array
    var characters = cleanText.replace(/\s+/g,'');
    
    // count characters
    var characterCount = characters.length;
    
    //***** Word Count and Sentence Count
    // create usable array from cleaned up text to count words
    var textArray = cleanText.split(/ /);
    
    // calculate number of words
    var wordCounts = textArray.length;
    
    // calculate the number of sentences
    var textForSentenceCount = textString.trim();
    var sentenceCount = textForSentenceCount.split(/[\.\?\!]\s/).length;
    //********
    
    // calculate the average number of characters per word
    var avgCharactersPerWord = (characterCount / wordCounts);        
    
    // calculate the average number of words per sentence
    var avgWordsPerSentence = (wordCounts / sentenceCount);
    
    // calculate the average number of characters per sentence
    var avgCharactersPerSentence = (characterCount / sentenceCount);
    
    // calculate the average syllables per word
    var avgSyllablesPerWord;
    avgSyllablesPerWord = (syllableCount / wordCounts);
    
    // calculate Automated Readablity Index        
    var automatedReadabilityIndex = (((4.71 * (characterCount / wordCounts)) + (0.5 * (wordCounts / sentenceCount)) - 21.43).toPrecision(4));
    
    // calculate Coleman Liau Index
    var colemanLiauIndex = (((5.88 * (characterCount / wordCounts)) - (0.296 * (sentenceCount / wordCounts)) - 15.8).toPrecision(4));
    
    // calculate Flesch Kincaid Reading Ease
   ...