Of course, there is no reason at all to even need that
alphabet function.
Code:
function start ()
{
var arrayPhrase = "Yesterday is history. Tomorrow is a mystery. But today is a gift. For this it is called present.";
var phrases = arrayPhrase.split(".");
var wordsPerPhrase = [ ];
var totalWords = 0;
for ( var p = 0; p < phrases.length - 1; ++p )
{
var words = phrases[p].replace(/^\s+/,"").replace(/\s+$/,"").split(" ");
wordsPerPhrase[p] = words.length;
totalWords += words.length;
}
alert ( "Total words = " + totalWords + "\n\n"
+ "Total phrases = " + phrases.length + "\n\n"
+ "Words in each phrase = " + wordsPerPhrase.join(", ")
);
}
start();