Question: This is my HTML code: Document Page Header Placeholder Home Product Main Content Area Product List ProdNum Description Price Fee Total p010 product 1 200
This is my HTML code:
Page Header Placeholder
- Home
- Product
Main Content Area
| ProdNum | Description | Price | Fee | Total |
|---|---|---|---|---|
| p010 | product 1 | 200 | 20 | 220 |
| p020 | product 2 | 100 | 0 | 100 |
| p100 | product 3 | 100 | 5 | 105 |
| p200 | product 4 | 200 | 0 | 200 |
| p300 | product 5 | 300 | 10 | 310 |
| p400 | product 6 | 150 | 0 | 150 |
This is what I need to do:
- Add a page activity.html to the site and update the navigation bar of all pages so that the activity page is accessible from all pages of the site.
- Create an activity.js file and link it to the activity page above the body closing tag. If you base this assignment on an earlier assignment and would like to have other features for the activity page, link other js files to the activity page as well.
Complete the following JavaScript Tasks, all in activity.js file
- Make a function createActivities() to do the following:
- Create at least 4 activity objects. One activity is made with object literal, one activity is created with a constructor function, and other two are created with an activity class. All activities have the same structure: 4 data members and 1 method. The 4 data members are: Activity Code, Description, Price, and Fee; the method is totalCost(), which returns the sum of the price and the fee of the activity. Make sure some activities charge a fee and others don't.
- Add all 4 activity objects to an array named activities.
- The function will return the activities array.
- Create a function showActivities() to do the following:
- The function accepts an argument, activityArray. Then it will present the activity information in the array with a web table, one activity per table row.
- Each activity's data member and the total cost (calculated with the totalCost method) will be displayed in its own table cell.
- If an activity's fee is 0, show "no fee". Here an if statement is expected.
- Show the web table in the page's main content area.
- Call the createActivities() function and assign the returned result to a variable activities. Do this above the 2 function definitions.
- Call the showActivities() function. Do this right below the statement invoking the createActivities(). The array returned from createActivities() will be passed into showActivities function.
By the end, in your activity.js file content would more or less look like the following:
// file header info
// invoking createActivities()
// invoking showActivities()
// function definitions
// Other features, if any.
The table would be like this:
| Activity Code | Description | Price | Fee | Total |
| vl64 | Vinh Long Tour | $1200 | $10 | $1210 |
| kg68 | Kien Giang Tour | $1300 | $20 | $1320 |
| ct65 | Can Tho Tour | $1500 | No Fee | $1500 |
| dt66 | Dong Thap Tour | $800 | $15 | $815 |
| tg63 | Tien Giang Tour | $900 | $10 | $910 |
| ag67 | An Giang Tour | $1100 | No Fee | $1100 |
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
