Question

In: Computer Science

JAVASCRIPT Create an array of 5 objects named "movies" Each object in the movies array, should...

JAVASCRIPT

  1. Create an array of 5 objects named "movies"
  2. Each object in the movies array, should have the following properties:
    • Movie Name
    • Director Name
    • Year Released
    • WasSuccessful (this should be a boolean and at least 2 should be false)
    • Genre
  3. Loop through all of the objects in Array
  4. If the movie is successful, display all the movie information on the page.

These movies were a success:

Title: Forrest Gump

  • Year Realeased: 1994
  • Director: Robert Zemeckis
  • Genre: Comedy

Solutions

Expert Solution


Output:

I've written code with comments.Please do read.

If you have any doubts/ If u want any modifications, please contact me:"[email protected]"


Please Do vote (Give Thumbs Up)

Raw Code:

<!DOCTYPE html>
<html>
<head>
   <title>Successful Movies</title>

   <script type="text/javascript">
       function movie_check(){
           document.write("<center><h1>Successful Movies</h1></center>");
           // Declaration of array of 5 objects named "movies".
           var movies = [
               {
                   MovieName:"The Terminal",
                   DirectorName:" Steven Spielberg",
                   YearReleased:2004,
                   WasSuccessful:true,
                   Genre:"Drama"
               },
               {
                   MovieName:"Forrest Gump",
                   DirectorName:"Robert Zemeckis",
                   YearReleased:1994,
                   WasSuccessful:true,
                   Genre:"Comedy"
               },
               {
                   MovieName:"Philadelphia",
                   DirectorName:"Jonathan Demme",
                   YearReleased:1993,
                   WasSuccessful:false,
                   Genre:"Trial drama"},
               {
                   MovieName:"Turner & Hooch",
                   DirectorName:"Roger Spottiswoode",
                   YearReleased:1989,
                   WasSuccessful:false,
                   Genre:"Action"
               },
               {
                   MovieName:"A Walk to Remember",
                   DirectorName:"Adam Shankman",
                   YearReleased:2002,
                   WasSuccessful:true,
                   Genre:"Melodrama/Drama"}
               ];

               for (i=0;i<movies.length;i++){
                   //Checking if the Movie is success or not
                   if (movies[i].WasSuccessful===true){
                       //If yes then we'll write the content to the site

                       document.write("<h3>Title:&nbsp;&nbsp;"+movies[i].MovieName+"</h3>");
                       document.write("Year Released:"+movies[i].YearReleased+"<br/>");
                       document.write("Director:"+movies[i].DirectorName+"<br/>");
                       document.write("Genre:"+movies[i].Genre+"<br/>");
                   }
               }
       }
   </script>
</head>
<body onload=movie_check()> <!--This will invoke the movie_check function in js,when you open this in browser -->
       <!-- Thanks Please Do Vote -->
</body>
</html>


Related Solutions

Javascript array of objects: I'm trying to get the input into an array of objects, and...
Javascript array of objects: I'm trying to get the input into an array of objects, and then display the information in a table using a for loop, but I don't think my path is right <!DOCTYPE html> <head> <title>Form</title> <meta charset="utf-8" /> <style media="screen"> h1 { text-align: center; } div { background-color: #pink; border: 2px solid green; padding: 15px; margin: 65px; } </style> <script> var list = []; total = 0; text = ""; function Product(item, quantity, costs){ this.item =...
Write the code to create an array named movies and store three of your favorite movies...
Write the code to create an array named movies and store three of your favorite movies in the array. Only provide the array and code needed to put the movie names in the array. Do not include additional code
Create a class named GameCharacter to define an object as follows: The class should contain class...
Create a class named GameCharacter to define an object as follows: The class should contain class variables for charName (a string to store the character's name), charType (a string to store the character's type), charHealth (an int to store the character's health rating), and charScore (an int to store the character's current score). Provide a constructor with parameters for the name, type, health and score and include code to assign the received values to the four class variables. Provide a...
Object-Oriented Design and Patterns in Java (the 3rd Edition Chapter 5) - Create a directory named...
Object-Oriented Design and Patterns in Java (the 3rd Edition Chapter 5) - Create a directory named as the question number and save the required solutions in the directory. - Each problem comes with an expected tester name. In the directory for a given problem, including the tester and all java classes successfully run this tester. Exercise 5.2 ObserverTester.java - Improve Exercise 1 by making the graph view editable. Attach a mouse listener to the panel that paints the graph. When...
Instructions Create an application to accept data for an array of five CertOfDeposit objects, and then...
Instructions Create an application to accept data for an array of five CertOfDeposit objects, and then display the data. import java.time.*; public class CertOfDeposit { private String certNum; private String lastName; private double balance; private LocalDate issueDate; private LocalDate maturityDate; public CertOfDeposit(String num, String name, double bal, LocalDate issue) { } public void setCertNum(String n) { } public void setName(String name) { } public void setBalance(double bal) { } public void issueDate(LocalDate date) { } public String getCertNum() { }...
JAVA Create a support class named RowSumThread.java from which you can instantiate Runnable objects, each of...
JAVA Create a support class named RowSumThread.java from which you can instantiate Runnable objects, each of which will sum one row of the two-dimensional array and then place the sum of that row into the appropriate slot of a one-dimensional, 20-element array. For your applicaiton, create MaxRowSum.java that instantiates a 20x20 two-dimentional array of integers, populates it with random integers drawn from the range 1 to 100, and then output the index of the row with the highest sum along...
Write a function in JAVASCRIPT that accepts an array as argument. The function should loop through...
Write a function in JAVASCRIPT that accepts an array as argument. The function should loop through the array elements and accumulate the sum of ASCII value of each character in element and return the total. For example: function([‘A’, ‘bc’, 12]); // returns 361 which is the sum of 65 + 98 + 99 + 49 + 50 Use of any built in string functions or built in array functions is not allowed, Any help would be much appreciated
Objectives: Sort data objects Compare the CPU efficiency between the object array and ArrayList used in...
Objectives: Sort data objects Compare the CPU efficiency between the object array and ArrayList used in the sorting operation. Input file: Data.csv (file is to big;I cannot update, you can use any data file) there are less than 20,000 records in Data.csv Your program will skip/reject dirty data lines. For example, if a line contains 2 fields, it is considered as a dirty data line and will be rejected/skipped by your program. You are required to develop a Java program...
Objectives: 1. Create classes to model objects Instructions: 1. Create a new folder named Lab6 and...
Objectives: 1. Create classes to model objects Instructions: 1. Create a new folder named Lab6 and save all your files for this lab into this new folder. 2. You can use any IDE (such as SciTE, NetBeans or Eclipse) or any online site (such as repl.it or onlinegdb.com) to develop your Java programs 3. All your programs must have good internal documentation. For information on internal documentation, refer to the lab guide. Problems [30 marks] Problem 1: The Account class...
Objectives: 1. Create classes to model objects Instructions: 1. Create a new folder named Lab6 and...
Objectives: 1. Create classes to model objects Instructions: 1. Create a new folder named Lab6 and save all your files for this lab into this new folder. 2. You can use any IDE (such as SciTE, NetBeans or Eclipse) or any online site (such as repl.it or onlinegdb.com) to develop your Java programs 3. All your programs must have good internal documentation. For information on internal documentation, refer to the lab guide. Problem : The Fraction class (Filename: TestFraction.java) Design...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT