how to check how many strings are in a sentence javascript

JavaScript
function WordCounter (str) {
	var words = str.split(" ").length;
	return words;
}
// this should work!
Source

Also in JavaScript: