Word Count

If you're new here, you may want to subscribe to my RSS feed. Thanks for visiting!

Returns the number of words in a string.

function wordcount(string:String):Number {
   var wrdArray:Array = string.split(" ");
   for (var i = wrdArray.length; i>0; i--) {
      if (wrdArray[i] == "") {
         wrdArray.splice(i,1);
      }
   }
   return wrdArray.length;
}
trace(wordcount("This will count the number of words"));


2 Responses to “Word Count”

  1. [...] bookmarks tagged flash Word Count saved by 4 others     hsmfreak9 bookmarked on 02/17/08 | [...]

  2. Joan says:

    This function is good! Love it!

Leave a Reply

Close
E-mail It