I've been doing this project for school, and everything works fine unless the length of text is longer than about 50 characters. If it is longer, everything will work except the array, which crashes the browser unless the script is stopped.
I am using the latest version of firefox.
I am fairly sure the problem is not my computer.
Here is my code:
<html>
<head>
<script language="JavaScript">
function MsgBox (textString){
alert(textString);
var pass=textString;
var numWo1=pass.split(" ");
var numWo=numWo1.length;
alert('The number of words: ' + numWo);
var numLet=pass.replace(/[^A-Z]/gi, "");
alert('The number of letters: ' + numLet.length);
var numSen1=pass.split(".");
var numSen2=pass.split("?");
var numSen3=pass.split("!");
var numSen=numSen1.length + numSen2.length + numSen3.length - 3
alert('The number of sentences: ' + numSen);
var avgWor=numWo / numSen;
alert('Average words per sentence: ' + avgWor);
var freFre1=pass.replace(/[.,!?-]/g, "");
var freFre=freFre1.split(" ");
var avgLet=numLet.length / numWo;
alert('Average letters per word: ' + avgLet);
var numCoun = 0;
var freLet1 = 0;
var freLet2 = 0;
var freLet3 = 0;
var freLet4 = 0;
var freLet5 = 0;
var freLet6 = 0;
var freLet7 = 0;
var freLet8 = 0;
var freLet9 = 0;
var freLet10 = 0;
var freLet11 = 0;
var freLet12 = 0;
var freLet13 = 0;
var freLet14 = 0;
var freLet15 = 0;
var freLet16 = 0;
var freLet17 = 0;
var freLet18 = 0;
var freLet19 = 0;
var freLet20 = 0;
while(numCoun != freFre.length){
if(freFre[numCoun].length == 1){
freLet1 = freLet1 + 1
numCoun = numCoun + 1}
else if(freFre[numCoun].length == 2){
freLet2 = freLet2 + 1
numCoun = numCoun + 1}
else if(freFre[numCoun].length == 3){
freLet3 = freLet3 + 1
numCoun = numCoun + 1}
else if(freFre[numCoun].length == 4){
freLet4 = freLet4 + 1
numCoun = numCoun + 1}
else if(freFre[numCoun].length == 5){
freLet5 = freLet5 + 1
numCoun = numCoun + 1}
else if(freFre[numCoun].length == 6){
freLet6 = freLet6 + 1
numCoun = numCoun + 1}
else if(freFre[numCoun].length == 7){
freLet7 = freLet7 + 1
numCoun = numCoun + 1}
else if(freFre[numCoun].length == 8){
freLet8 = freLet8 + 1
numCoun = numCoun + 1}
else if(freFre[numCoun].length == 9){
freLet9 = freLet9 + 1
numCoun = numCoun + 1}
else if(freFre[numCoun].length == 10){
freLet10 = freLet10 + 1
numCoun = numCoun + 1}
else if(freFre[numCoun].length == 11){
freLet11 = freLet11 + 1
numCoun = numCoun + 1}
else if(freFre[numCoun].length == 12){
freLet12 = freLet12 + 1
numCoun = numCoun + 1}
else if(freFre[numCoun].lenth == 13){
freLet13 = freLet13 + 1
numCoun = numCoun + 1}
else if(freFre[numCoun].length == 14){
freLet14 = freLet14 + 1
numCoun = numCoun + 1}
else if(freFre[numCoun].length == 15){
freLet15 = freLet15 + 1
numCoun = numCoun + 1}
else if(freFre[numCoun].length == 16){
freLet16 = freLet16 + 1
numCoun = numCoun + 1}
else if(freFre[numCoun].length == 17){
freLet17 = freLet17 + 1
numCoun = numCoun + 1}
else if(freFre[numCoun].length == 18){
freLet18 = freLet18 + 1
numCoun = numCoun + 1}
else if(freFre[numCoun].length == 19){
freLet19 = freLet19 + 1
numCoun = numCoun + 1}
else if(freFre[numCoun].lenth == 20){
freLet20 = freLet20 + 1
numCoun = numCoun + 1}
}
alert('Frequency of word length' + '\n1 Letter: ' + freLet1 + '\n2 Letters: ' + freLet2 + '\n3 Letters: ' + freLet3 + '\n4 Letters: ' + freLet4 + '\n5 Letters: ' + freLet5 + '\n6 Letters: ' + freLet6 + '\n7 Letters: ' + freLet7 + '\n8 Letters: ' + freLet8 + '\n9 Letters: ' + freLet9 + '\n10 Letters: ' + freLet10 + '\n11 Letters: ' + freLet11 + '\n12 Letters: ' + freLet12 + '\n13 Letters: ' + freLet13 + '\n14 Letters: ' + freLet14 + '\n15 Letters: ' + freLet15 + '\n16 Letters: ' + freLet16 + '\n17 Letters: ' + freLet17 + '\n18 Letters: ' + freLet18 + '\n19 Letters: ' + freLet19 + '\n20 Letters: ' + freLet20);
}
</script>
</head>
<body>
<form>
<input name="passa" TYPE=Text>
<input name="submit" TYPE=Button VALUE="Show Me" onClick="MsgBox(form.passa.value)">
</form>
</body>
</html>
--- Update ---
well found my first error, mispelled the word length xD
--- Update ---
even though i fixed that error, the code still does not work if it is the string is too long