A blog & community for non-professional web designers, programmers, webmasters, and other web savvies.

Javascript Word Count

February 28, 2011 - 12:00am -- Thomas

This script will calculate how many words are in your string. Do not use double spaces because those count as one word.

<script type="text/javascript"><!--
// ***************
// Javascript Word Count
// More JavaScript Scripts at
// http://icecaves.net/tags/javascript
// ***************
var string = "Put your text here. Javascript will calculate how many words are in your string.";
var total = string.split(" ").length;
document.write("String: " +string+ "<br>Word Count: " +total);
//-->
</script>
Code Preview: 
Forum Board: 

@IceCaves on Twitter

    Stay Connected

    Twitter Facebook Tumblr Google+ Glaciallis Google RSS

    *Follow us on Twitter or Facebook to also follow minor site updates that don't make it to the homepage news.