กก
If we need to perform repetitive procedure or processes in JavaScript, we could achieve it by using the While statement. The while statement allows us to control the number of times a procedure is performed. It is important to make that the repetition is not endless. I will illustrate the algorithm using the example bellow. The program will produce a pop-up dialog box 8 times prompting the user to enter the marks 8 times, then it will add up the marks and show the average mark.:
Example:
| กก |
Click on the testing page |
กก