Sovi.AI - AI Math Tutor

Scan to solve math questions

QUESTION IMAGE

define a setter function named wonaward () that takes a parameter for t…

Question

define a setter function named wonaward () that takes a parameter for the name of an the end of the awards array. 1 // code will be tested with a different movie 2 let movie = { 3 title: \forrest gump\, 4 director:
obert zemeckis\, 5 composer: \alan silvestri\, 6 budget: 55000000, 7 boxoffice: 677900000, 8 awards: , 9 wonaward: function(awardname) { 10 this.awards.push(awardname); 11 } 12 }; check try again testing with wonaward = \best picture\ yours and expected differ. see highlights below. special character legend yours expected best picture testing with wonaward = \best director\, and wonaward = \best visual effects\ yours and expected differ. see highlights below. special character legend yours expected best director, best visual effects

Explanation:

Step1: Define the function

In JavaScript, to define a function named wonAward inside the movie object that takes a parameter awardname and pushes it to the awards array, we use the syntax wonAward: function(awardname) { ... }.

Step2: Push the award name

Inside the function, we use the push method on the awards array. The this keyword refers to the movie object. So the code inside the function is this.awards.push(awardname);.

Answer:

let movie = {
    title: "Forrest Gump",
    director: "Robert Zemeckis",
    composer: "Alan Silvestri",
    budget: 55000000,
    boxOffice: 677900000,
    awards: [],
    wonAward: function(awardname) {
        this.awards.push(awardname);
    }
};