Project: lb_imdb
JavaScript·4 min read·Apr 8, 2025
The objective of this project is to write a script that recommends a movie title based on a genre and a decade.
General instructions
Here are the general instructions to complete this project:
-
The script must be named
lb_imdb.js. -
The script must be written in JavaScript.
Implementation
Here are the implementation details for this project:
-
The script must only use:
- Variables (e.g.,
let,const). - Conditional statements (e.g.,
if,else,switch). - Comparison operators (e.g.,
==,!==).
- Variables (e.g.,
-
The script must include and start with two global variables named
genreanddecade:lb_imdb.jsconst genre; const decade;Where:
genreis a string that represents the genre of a movie (e.g.,'War','Action').decadeis an integer that represents the decade in which a movie was released (e.g.,1990,2000).
-
Based on the value of the
genreanddecadevariables, the script must recommend a movie title in the following list:-
Action:
- Timecop (1994) – 99 minutes
- Gladiator (2000) – 155 minutes
-
War:
- Saving Private Ryan (1998) – 169 minutes
- Black Hawk Down (2001) – 144 minutes
-
Comedy:
- The Hangover (2009) – 100 minutes
-
Usage
Here is how the script should behave in different scenarios:
-
If a movie matches the value of both the
genreanddecadevariables, the script must output its name.For example, considering the following values:
lb_imdb.jsconst genre = 'Action'; const decade = 1990; // ...When executed, the script should produce this output:
$ node lb_imdb.js Timecop (1994) – 99 minutes -
If none of the movies match the value of the
genrenor thedecadevariable, the script must output an error.For example, considering the following values:
lb_imdb.jsconst genre = 'Romance'; const decade = 1960; // ...When executed, the script should produce this output:
$ node lb_imdb.js Error: Movie not found
Hints
Here are some useful hints to solve this project:
-
In JavaScript, you can output the value of an expression to the terminal by specifying it between the parentheses
()of the theconsole.log()function.const title = "Timecop (1994) – 99 minutes"; console.log(title);