# can someone help me debug this program??

This topic is 3592 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

<html> <head><title>Final Exam Debug</title> <script type="text/javascript"> function Calculate(f){ var sum, ctr; for(ctr=0, ctr<=4, ctr++){ sum = elementsArray[ctr].value; } //end of for loop f.sumBox.value = sum; f.averageBox.value = sum/4; } //end of function </script> </head> <body> Please enter four numbers in the boxes below: <br/> <form id="numbersForm" name="numbersForm"> <input type="text" name="num1Box" size="5"/><br/> <input type="text" name="num2Box" size="5"/><br/> <input type="text" name="num3Box" size="5"/><br/> <input type="text" name="num4Box" size="5"/>

<input type="button" value="Calculate Sum and Average" onclick="calculate(document)">

The sum is: <input type="text" name="sumBox" size="6"/><br/> The average is: <input type="text" name="averageBox" size="6"/><br/> </form> </body> </html>

##### Share on other sites
what's the problem?

##### Share on other sites
Your debugger has probably already told you that "elementsArray" is not defined. So, why don't you define it?

##### Share on other sites
Is this a homework question? It says "Final Exam" at the top. Anyway, ToohrVyk is correct, it is probably worth defining elementsArray.

1. 1
Rutin
46
2. 2
3. 3
4. 4
5. 5
JoeJ
19

• 11
• 14
• 9
• 10
• 12
• ### Forum Statistics

• Total Topics
633004
• Total Posts
3009833
• ### Who's Online (See full list)

There are no registered users currently online

×