Ask Question
29 August, 16:47

Define a method named roleOf that takes the name of an actor as an argument and returns that actor's role. If the actor is not in the movie return "Not in this movie.". Ex: roleOf ("Jessica Chastain") returns "Murph". Hint: A method may access the object's properties using the keyword this. Ex: this. cast accesses the object's cast property.

+1
Answers (1)
  1. 29 August, 18:42
    0
    var movie = {

    / / Code will be tested with different actors and movies

    name: "Interstellar",

    director: "Christopher Nolan",

    composer: "Hans Zimmer",

    cast: {

    "Matthew McConaughey": "Cooper",

    "Anne Hathaway": "Brand",

    "Jessica Chastain": "Murph",

    "Matt Damon": "Mann",

    "Mackenzie Foy": "Young Murph"

    },

    roleOf: function (actorName) {

    if (! (actorName in this. cast)) {

    return "Not in this movie.";

    }

    return this. cast[actorName];

    }

    };
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Define a method named roleOf that takes the name of an actor as an argument and returns that actor's role. If the actor is not in the movie ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers