Dynamic Web Sites - Exercises with Examples

Try to Table That!

After completing the calculator, you should be a pro at building user-defined functions. So, let's revisit the HTML table builder from Exercise #2, and incrementally improve the code by introducing a function.

Exercise #5

A. Move the loop structure that builds the table rows into a function named TableRows(). What arguments will you need to pass when you call TableRows()? Be sure to include them in your function definition. What about a return value? What does the loop itself do? Does it return something or do something?

If a function performs an output operation, it does not need to include a return statement. In Java, such a function, or method as they're called, would return a void result, which means the function executes its operation and simply lets the system know whether it passed or failed.

B. Write three new sequences to build three different tables, each time calling TableRows() with different values for its arguments.