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

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
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 =...
please use C++ Create a class named Byte that encapsulates an array of 8 Bit objects....
please use C++ Create a class named Byte that encapsulates an array of 8 Bit objects. The Byte class will provide the following member functions: Byte - word: Bit[8] static Bit array defaults to all Bits false + BITS_PER_BYTE: Integer16 Size of a byte constant in Bits; 8 + Byte() default constructor + Byte(Byte) copy constructor + set(Integer): void sets Bit to true + clear(): void sets to 0 + load(Byte): void sets Byte to the passed Byte + read():...
JAVASCRIPT: Please create an array of student names and another array of student grades. - Create...
JAVASCRIPT: Please create an array of student names and another array of student grades. - Create a function that can put a name and a grade to the arrays. - Keep Read student name and grade until student name is “???”. And save the reading by using a function - Create another function to show all the grade in that object. - Create the third function that can display the maximum grade and the student’s name. - Create a sorting...
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...
JAVASCRIPT: - Please create an object (grade) with 10 names and 10 grades. - Create a...
JAVASCRIPT: - Please create an object (grade) with 10 names and 10 grades. - Create a method (inputGrade) that can put a name and a grade to the grade object. - Create another method (showAlltheGrades) to show all the grade in that object. - Create the third method (MaxGrade) that can display the maximum grade and the student name. - Using “prompt” and inputGrade method input 10 student names and their grades. - Display all the grades and names by...
JAVASCRIPT: - Please create an object (grade) with 10 names and 10 grades. - Create a...
JAVASCRIPT: - Please create an object (grade) with 10 names and 10 grades. - Create a method (inputGrade) that can put a name and a grade to the grade object. - Create another method (showAlltheGrades) to show all the grade in that object. - Create the third method (MaxGrade) that can display the maximum grade and the student name. - Using “prompt” and inputGrade method input 10 student names and their grades. - Display all the grades and names by...
Define a function in Javascript named secondHighest which accepts an array of numbers, and returns the...
Define a function in Javascript named secondHighest which accepts an array of numbers, and returns the second highest number from the array. If the highest value occurs more than once, then it is also the second highest (see example). Assume the input array will always have length at least two (so there is always a second highest value). The original array must NOT be modified by this function. Example secondHighest([5,3,8,6,2,7,4]) must return 7, and secondHighest([5,3,8,6,2,7,8]) must return 8. I have...
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() { }...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT