JavaScript Basics: Count the words in a string
This is a quick function to count the words in a given string.
<script>
function wordCount(str){
return str.split(' ').length;
}
console.log(wordCount('Hello, how are you?'))
</script>
Categories: Javascript