Advertisement
GustavoAraujo

CharsCount

Sep 5th, 2014
309
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <script language='javascript'>
  2. function CharsCount(string)
  3. {
  4.     var nLen = string.length;
  5.     var Words = 0;
  6.     for(var i = 0; i < nLen; i++)
  7.     {
  8.         if(string[i+1] == ' ' && string[i+2] == ' ') continue;
  9.         if(string[i+1] == ' ' || i+1 == nLen ) Words++;
  10.     }
  11.     alert("Was counted '" + Words + "' words and '"+nLen+"' characters.");
  12. }
  13. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement