WDV 221 Intro to JavaScript

JavaScript Objects

Use the following parallel arrays to create a set of objects:

let bookTitles = ["Beginning Javascript", "Logic with ES6", "Javascript Ojbects Made Easy"];

let bookPrices = [19.99, 29.49, 999.99];

let bookAuthor = ["Smith", "Johson-Parker", "Westin" ];

For you assignment:

Part 1

  1. Create a class called masterBook that defines three properties: bookTitle, bookPrice, bookAuthor
  2. In the masterBook class define a method call studentDiscountPrice( ). The method will return the bookPrice discounted by 20%. The return value should be formatted as currency.
  3. On your page create the javascript parallel arrays shown above.
  4. Create a script that will create and load three book objects from the masterBook class called book1, book2, book3 using the data from the parallel arrays.
  5. Display the contents of each book object on the console.
  6. Create a Javascript array called javascriptBooks. Load the book objects into the array.
  7. Use a loop to process the contents of the javascriptBooks array. Display all the information for each book on the web page. This includes calling the studentDiscountPrice( ).

(results go here)

Part 2

  1. Create a script that will create and load three book objects called bookA, bookB, bookC using the object literal { } method. Use the same properties and methods from Part 1.
  2. Display the contents of each book object on the console.
  3. Create a JavaScript array called newBooks. Load these book objects into the array.
  4. Use a loop to process the contents of the newBooks array. Display all information for each book on the web page. This includes calling the studentDiscountPrice( ).