Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need help with this javascript question, please add to the template and answer with javascript code please. It was one question but I split

I need help with this javascript question, please add to the template and answer with javascript code please. It was one question but I split it into steps to make it easier. Also if you can add comments explaining what's going on in the code, that would be much appreciated. Template is below. I posted what the output should look like as well, if you use the sample information I posted on the bottom.

Page Title Here

image text in transcribed

Sample information to be inputted

image text in transcribed

Result on website

image text in transcribed

Code a JavaScript constructor function called VideoType that will handle the following set of properties: title (string) category (string) cast (string array) price (number) numRents (number) vidRevenue (number) Whenever a new object is created, the first 4 properties will need to be passed into the constructor function as parameters and the last 2 (numRents and vidRevenue) should be initialized to 0 and 0.0 respectively. In addition to these object level properties, create a prototype level numeric variable called totRevenue which is attached to the Video Type constructor function. As such, this single variable will be visible to all objects created using the constructor function. See the Methods2.html example for more information. Next, create a JavaScript method called procRental which takes no parameters. The purpose of this method is to process a video rental transaction which includes: a. Incrementing the total number of rentals for the video (numRents) b. Incrementing the total rental revenues for the video (vidRevenue) c. Incrementing the total rental revenues for all videos (totRevenue) Create an onload" event handler which will call a JavaScript function named StartMeUp and within StartMeUp create an empty array called videos. Do all the rest of the steps from within StartMeUp Using the sample data listed below and your VideoType" constructor function, create 3 new video objects as the first 3 elements in the array (videos [0], videos [1], and videos [2]). See the Methods 1.html" example for more information on how to handle the cas array. Now, add a two-level nested for loop to the StartMeUp function to test your application. The outer loop should cycle through 5 times and the inner loop will use a call to the procRental method to simulate the processing of a rental for each of your videos. The inner loop must cycle as many times as there are video objects. Finally, use document.write to print out all the properties for all the video objects in the videos array as well as a total Rental $ amount for each video and a grand total $ for all the videos rented. See the sample output below for the required formatted output. Title Rogue one Category Sci-Fi Price 17.95 Arrival Sci-Fi 17.95 Cast Felicity Mads Mikkelsen Riz Ahmed Amy Adams Jeremy Renner Daniel craig Leah Seydoux Rami Malek Lashana lynch No time to die Adventure 28.95 Rogue One, SciFi, $17.95, 5, $89.75 Cast: Felicity Jones Mads Mikkelsen Riz Ahmed Arrival, SciFi, $17.95, 5, $89.75 Cast: Amy Adams Jeremy Renner No Time to Die, Adventure, $28.95, 5, $144.75 Cast: Daniel Craig Lea Seydoux Rami Malek Lashana Lynch Total Rental Revenue: $324.25

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Practical Azure SQL Database For Modern Developers Building Applications In The Microsoft Cloud

Authors: Davide Mauri, Silvano Coriani, Anna Hoffma, Sanjay Mishra, Jovan Popovic

1st Edition

1484263693, 978-1484263693

More Books

Students also viewed these Databases questions

Question

3 How supply and demand together determine market equilibrium.

Answered: 1 week ago