Question: JavaScript #1 part 1 Define a getter function named totalRevenue that subtracts budget to boxOffice and returns the result. code- var movie = { //

JavaScript

#1 part 1

Define a getter function named totalRevenue that subtracts budget to boxOffice and returns the result.

code-

var movie = { // Code will be tested with a different movie name: "Forrest Gump", director: "Robert Zemeckis", composer: "Alan Silvestri", cast: { "Tom Hanks": "Forrest Gump", "Michael Connor Humphreys": "Young Forrest Gump", "Robin Wright": "Jenny Curran", "Gary Sinise": "Lieutenant Dan Taylor" }, budget: 55000000, boxOffice: 677900000, awards: [],

totalRevenue: function(){ var inch = this.boxOffice - this.budget; return inch; } };

---------------------------------------------------------------------------------

#1 part 2

Display the date when Microsoft was founded in M-DD-YYYY format. Ex: The 31st of January 1970 should be displayed as: "1-31-1970".

code-

var interestingEvents = { "Long distance telegraph": new Date(1844, 4, 24), "First telephone call": new Date(1876, 2, 10), "Microsoft founded": new Date(1975, 3, 4), "World wide web born": new Date(1989, 2, 1), "Google founded": new Date(1998, 8, 4), "Facebook website launch": new Date(2004, 1, 4) }; var interestingDate = interestingEvents["Microsoft founded"]; // Code also tested using date of First telephone call

/* Your solution goes here */

-------------------------------------------------------------------------------------

#1 part 3

Surround the call to processNumbers with a try-catch statement. The catch block should display the thrown message.

code-

var numList = [ 1, 2, 5, 7 ]; // Code will be tested with different arrays. var processedValue = 0;

try { processedValue = processNumbers(numList); } catch (err) { console.log(err.message); }

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!