Define a method named orderOfAppearance() that takes the name of a role as an argument and returns that role's order of appearance. If the role is not found, the method returns 0. Ex: orderOfAppearance("Forrest Gump") returns 1. Hint: A method may access the object's properties using the keyword this. Ex: this.title accesses the object's title property.

// Code will be tested with different roles and movies
let movie = {
title: "Forrest Gump",
director: "Robert Zemeckis",
composer: "Alan Silvestri",
roles: [ // Roles are stored in order of appearance
"Forrest Gump",
"Young Forrest Gump",
"Jenny Curran",
"Lieutenant Dan Taylor"
],
orderOfAppearance: function(role) {

}
};

Respuesta :

The method named orderOfAppearance() that takes the name of a role as an argument is; Written as below

How to write a Program in Java?

The steps to write this Java program is as follows;

  • 1) Initialize the movie JSON (JavaScript Object Notation) having the name, director, composer and title properties.
  • 2) Define a roleOf: function that has a name parameter.
  • 3) Check whether the selected is not equal to undefined and then return that name.
  • 4) Otherwise display this message: "0".

let movie = {

  name: "Forrest Gump",

  director: "Robert Zemeckis",

  composer: "Alan Silvestri",

  title: {

      "Forrest Gump",

      "Young Forrest Gump"

      "Jenny Curran"  

       "Lieutenant Dan Taylor"            

  },

  orderOfAppearance: function (role) {

      if (typeof (this.title[role]) !== 'undefined') {

          return this.title[role];

      } else {

          return "0";

      }

  }

};

Read more about java programming at; https://brainly.com/question/16397886