-
Сount the number of words in a text
I have a task to count the number of words in a text. Here is an expression that works for this:
txt=text.sourceText;
varvalAry = txt.value.split(” “);
var curLine = “”;
for (var i=0;i<valAry.length;i++){
curLine = i + ” ” +” “;}
But if I add a space at the end of the text, then the expression considers the last space as a word.
Please help me how to make a random space after the text not be considered as a word.