MM101 Lab 7

In this lab you will do some short exercises designed to assist with the first project.

Need help?

If you need help put your hand up, or get our attention some other way. We'll be talking to everyone but if we know you're stuck and waiting for help then you get priority.

  1. Displaying A Fixed Grid
  2. Modifying a Location
  3. Filling a Grid
  4. hint

Part 1 Displaying a Fixed Grid

Write a script that populates an array of length 20 with random numbers, and then displays it as a 5 by 4 grid (4 rows of length 5)

A table with two rows and two columns can be done in html as

Implement your solution so it is easy to change the number of numbers, rows and columns.

Part 2 Modifying a Location

Extend the script of part 1 so that, after filling and displaying the grid, it prompts for two numbers: the first is an index into the array, while the second is a replacement number.

The array should be updated and the revised table displayed below the initial random one.

Part 3 Filling a Grid

Modify the script of part 2 as follows:

Hint(Tables in HTML)

Use your browsers "View Source" (Ctrl-U, View Menu in Firefox) to see how the table below was generated:
1 2 3
4 5 6