Question: Complete the following JavaScript Tasks, all in activities.js file. Make a function createActivities() to do the following: Create at least 4 activity objects. One is

Complete the following JavaScript Tasks, all in activities.js file.

  1. Make a function createActivities() to do the following:
    1. Create at least 4 activity objects. One is created with object literal, one is created with a constructor function, and the other two are created with an activity class. NOTE: in a real project, you won't do it this way but here is just for your practice with different object creation methods. 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.
    2. Add all 4 activity objects to an array named activities.
    3. The function will return the activities array.
  2. Create a function showActivities() to do the following:
    1. 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.
    2. Each activity's data member and the total cost (calculated with the totalCost method) will be displayed in its own table cell.
    3. If an activity's fee is 0, show "no fee". Here, an if statement is expected.
    4. Show the web table in the page's main content area.
  3. Call the createActivities() function and assign the returned result to a variable activities. Put this statement right above the function definitions.
  4. Call the showActivities() function. Put this statement right below the statement invoking the createActivities(). The array returned from createActivities() will be passed into showActivities function.

    By the end, your activities.js file content would more or less look like the following:

    // file header info

    // invoking createActivities()

    // invoking showActivities()

    // function definitions

    // Other features, if any.

  5. The table would be something like this, you can add anything as you like:

  6. Complete the following JavaScript Tasks, all in activities.js file. Make a function

Activity Code Description Price Fee Total v164 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!