Learn free online HTML5, javascript, and jquery Tutorials by Examples

Sunday, 11 January 2015

Count number of word from given string using javascript

<script>
var str = "satish mallick.";
var wordCount = str.match(/(\w+)/g).length;
alert(wordCount);

</script>

No comments:

Post a Comment