In: Computer Science
JAVASCRIPT
These movies were a success:
Title: Forrest Gump
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: "+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>