Lab 6 - Object

Lab 6 objective

In this assignment you will build and use Objects.

You may wish to look at the samples in Unit 9 - Objects.

Table and heading

Build a page named lab6.html

This lab extends the work you did in lab 3. Change the constructor from lab 3, so it also builds the isbn property. Now, the separate function to add the isbn property is not needed.

Put a link in your index page to your new page. Also, put a link from this page back to your index page.

Before we start to add JavaScript we will build a table with a heading row.

Put a heading at the top of the page. Then build a table and heading row. The heading data is:

  • Title
  • Author
  • © date
  • Publisher
  • ISBN
  • price

One data row

For our class text book, use the six data items corresponding to the six heading items. Use your new constructor function to build an Object with the six data items for our text book in your object. Name the object book1. Use the same data as in the lab 3.

Build a method for your Book objects, that will write the tr and td elements, as well as the data from the book object, into a new second row in the table.

Make the table look good. If this is all good, it earns 18 out of 20 points, a low A.

More data rows

If you wish, you may do this section to earn a high A.

Find four additional books that deal with JavaScript or related technologies.

Create an array, called mainArray, with five entries (for our text and four more books). Each entry will be a reference to a book object. Each of these five book objects will contain the data for one book.

Write a loop, that goes through the five entries in the main array. Each of the five references will be processed by the same methods, which were used when there was only one book to be processed.

The result will be a table with a header row and five book rows.