In javascript Define a setter function named wonAward that takes a parameter for
ID: 3602321 • Letter: I
Question
In javascript
Define a setter function named wonAward that takes a parameter for the name of an award and stores the award name in the awards array 1 var movie { // Code will be tested with a different movie name: "The Lord of the Rings: The Fellowship of the Ring", director: "Peter Jackson", composer "Hoard Shore", 4 5 cast: "Elijah lood": "Frodo Baggins", "Sean Astin": "Samwise Gamgee", "Ian McKellen" "Gandalf", "Viggo Mortensen" "Aragorn", "Orlando Bloom: "Legolas", "Christopher Lee": "Saruman" 12 , 13 budget 93000000, boxOffice: 871500000, 15 awards: 16 17 Your solution goes here */ 18 19 1Explanation / Answer
var movie={
name:"The Lord",
// add remaining columns here.
awards:[],
//function wonAward to add an award to array.
wonAward:function(award_name){
//push the award_name to awards
this.awards.push(award_name);
}
}
movie.wonAward("OSCAR");
console.log(movie.awards);
/*
output
['OSCAR']
*/
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.