Project: lb_imdb

JavaScript·4 min read·Apr 8, 2025

movie streaming illustration

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:

  1. The script must be named lb_imdb.js.

  2. The script must be written in JavaScript.

Implementation

Here are the implementation details for this project:

  1. The script must only use:

    • Variables (e.g., let, const).
    • Conditional statements (e.g., if, else, switch).
    • Comparison operators (e.g., ==, !==).
  2. The script must include and start with two global variables named genre and decade:

    lb_imdb.js
    const genre;
    const decade;
    

    Where:

    • genre is a string that represents the genre of a movie (e.g., 'War', 'Action').
    • decade is an integer that represents the decade in which a movie was released (e.g., 1990, 2000).
  3. Based on the value of the genre and decade variables, 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:

  1. If a movie matches the value of both the genre and decade variables, the script must output its name.

    For example, considering the following values:

    lb_imdb.js
    const genre = 'Action';
    const decade = 1990;
    
    // ...
    

    When executed, the script should produce this output:

    $ node lb_imdb.js
    Timecop (1994)99 minutes
    
  2. If none of the movies match the value of the genre nor the decade variable, the script must output an error.

    For example, considering the following values:

    lb_imdb.js
    const 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:

  1. In JavaScript, you can output the value of an expression to the terminal by specifying it between the parentheses () of the the console.log() function.

    const title = "Timecop (1994) – 99 minutes";
    
    console.log(title);