Count number of characters in each paragraph

i am trying to find a way to count the number of characters in every paragraph on a page. I discovered this little snippet below which counts the number of words in each paragraph and it works great. Could it be modified to also include the number of characters as well. There are a bunch of solutions all over the internet but they only focus on a specific string or text area and tend to get really long and intricate. I dont mind if the spaces or special characters are included in the count.

Here is the snippet. It is a really neat little piece of code.

$(document).ready(function() {
    $('p').each(function(i) {
        var iTotalWords = $(this).text().split(' ').length;
        $(this).append("<b> " + iTotalWords + " words </b>");
    });
})

Thanks in advance.

Answer

here is the solution:

var count = $('p').text().length;

So your code will be like:

$(document).ready(function() {
    $('p').each(function(i) {
        var iTotalWords = $(this).text().split(' ').length;
        var charCount = $(this).text().length;
        $(this).append("<b> " + iTotalWords + " words and " + charCount + " chars </b>");
    });
})

Hope this helps you ;D