Cara memeriksa berapa banyak string dalam kalimat JavaScript

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