saeraa / mellankalix

Biograf för Mellankalix
2 stars 3 forks source link

[3] Funktion: Filtrera film kort #33

Closed saeraa closed 1 year ago

saeraa commented 1 year ago

Details

Create a function that will take the full array of movies and return a filtered version, depending on a parameter.

Visningstider: Return movies that have a showtime in the coming 2 days. På bio just nu: Return max 21 random. Karusell: Return 4 random. Kommande premiärer: Movies with a premier date spanning from today onwards. Klassiker: Movies released up to 1990. Salong x: Movies shown in salon x.

Example (pseudo code)

function filterMovies(array, parameter) {
  let results = [];
  switch (parameter)
    case "1990": 
        results = array.filter(movie => movie.premiere < 1990)
  break;
  return results;
}

User story

As a developer, I need a function to be able to get the movies I need to show at this particular page.

Definition of done

You should be able to send in an array of movies and get the results depending on what parameter you send in.

Tests

If you send an array of movies with the parameter 1990, the result you get back should be movies released before 1990.

saeraa commented 1 year ago

Pull request

Arash-SJPI22 commented 1 year ago

Tested, all parameters return correct results