-
Notifications
You must be signed in to change notification settings - Fork 33
/
index.js
174 lines (165 loc) · 5.81 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
/*
Do not change the line below. If you'd like to run code from this file, you may use the `exampleMovies` variable below to gain access to an array of movies.
Keep in mind that your functions must still have and use a parameter for accepting all movies.
*/
const exampleMovies = require("./movies");
// Do not change the line above.
/**
* getAllMovieTitles()
* -----------------------------
* Returns all of titles from an array of movies. If the inputted `movies` array is empty, throw an error with a message.
* @param {Object[]} movies - An array of movies. See the `movies.js` file for an example of this array.
* @returns {string[]|Error} An array of strings, which are movie titles.
*
* NOTE: You must use the `.map()` method.
*
* EXAMPLE:
* getAllMovieTitles(movies);
* //> [
"Toy Story 4",
"Inside Out",
"Coco",
"Incredibles 2",
"Moana",
"How to Train Your Dragon",
"Paddington",
"The Lion King",
"Fantasia",
"James and the Giant Peach",
];
*/
function getAllMovieTitles() {}
/**
* checkIfAnyMovieHasRating()
* -----------------------------
* Returns a boolean, representing whether or not any of the movies has been given the provided rating. If the inputted `movies` array is empty, throw an error with a message.
* @param {Object[]} movies - An array of movies. See the `movies.js` file for an example of this array.
* @param {string} [rating="G"] - A movie rating. Defaults to "G".
* @returns {boolean|Error} Returns `true` if a movie exists in the list with the given rating, otherwise returns `false`.
*
* NOTE: You must use the `.some()` method.
*
* EXAMPLE:
* checkIfAnyMovieHasRating(movies, "G");
* //> true
*
* EXAMPLE:
* checkIfAnyMovieHasRating(movies, "R");
* //> false
*/
function checkIfAnyMovieHasRating() {}
/**
* findById()
* -----------------------------
* Returns a movie object from an array of objects based on the ID. If the inputted `movies` array is empty, throw an error with a message. If the ID does not match any movie, return `null`.
* @param {Object[]} movies - An array of movies. See the `movies.js` file for an example of this array.
* @param {string} id - A unique `imdbID`.
* @returns {Object|Error|null} The movie object with the matching `imdbID`.
*
* NOTE: You must use the `.find()` method.
*
* EXAMPLE:
* findById(movies, "tt1979376");
* //> {
// Toy Story 4
};
*/
function findById() {}
/**
* filterByGenre()
* -----------------------------
* Returns all movie objects with a matching genre. Case-insensitive. If the inputted `movies` array is empty, throw an error with a message. If no movies match the inputted `genre`, return `[]`.
* @param {Object[]} movies - An array of movies. See the `movies.js` file for an example of this array.
* @param {string} genre - The genre of a movie. (e.g. "Fantasy")
* @returns {Object[]|Error} An array of movies where at least one of the genres matches the `genre` inputted.
*
* NOTE: You must use the `.filter()` method.
*
* EXAMPLE:
* filterByGenre(movies, "Mystery");
* //> [
{
// Coco
}
]
*
* EXAMPLE:
* filterByGenre(movies, "Horror")
* //> []
*/
function filterByGenre() {}
/**
* getAllMoviesReleasedAtOrBeforeYear()
* -----------------------------
* Returns all movie objects with a `released` year equal to or less than the given year. If the movie array is empty, throw an error with a message.
* @param {Object[]} movies - An array of movies. See the `movies.js` file for an example of this array.
* @param {number} year - A year as a number. (e.g. 2000)
* @returns {Object[]|Error} An array of movies where the `released` year is equal to or less than the inputted year.
*
* NOTE: You must use the `.filter()` method.
*
* EXAMPLE:
* getAllMoviesReleasedAtOrBeforeYear(movies, 2000);
* //> [
{
// The Lion King
},
{
// Fantasia
},
{
// James and the Giant Peach
}
];
*/
function getAllMoviesReleasedAtOrBeforeYear() {}
/**
* checkMinMetascores()
* -----------------------------
* Returns either true or false depending whether all movies have a minimum metascore. If the movie array is empty, throw an error with a message.
* @param {Object[]} movies - An array of movies. See the `movies.js` file for an example of this array.
* @param {number} metascore - A minimum metascore number. (e.g. 80)
* @returns {Boolean|Error} A boolean
*
* NOTE: You must use the .every()` method.
*
* EXAMPLE:
* checkMinMetascores(movies, 90));
* //> false
*/
function checkMinMetascores() {}
/**
* getRottenTomatoesScoreByMovie()
* -----------------------------
* Transform each movie, returning an array of objects where the key is the title of the movie and the value is the score received from Rotten Tomatoes. If there are no movies, throw an error with a message.
* @param {Object[]} movies - An array of movies. See the `movies.js` file for an example of this array.
* @returns {Object[]|Error} An array of movie objects where the key is the movie title and the value is the score received from Rotten Tomatoes.
*
* NOTE: You must use both the `.map()` method and the `.find()` method.
*
* EXAMPLE:
* getRottenTomatoesScoreByMovie(movies);
* //> [
{ "Toy Story 4": "97%" },
{ "Inside Out": "98%" },
{ Coco: "97%" },
{ "Incredibles 2": "93%" },
{ Moana: "95%" },
{ "How to Train Your Dragon": "99%" },
{ Paddington: "97%" },
{ "The Lion King": "93%" },
{ Fantasia: "95%" },
{ "James and the Giant Peach": "91%" },
];
*/
function getRottenTomatoesScoreByMovie() {}
// Do not change anything below this line.
module.exports = {
getAllMovieTitles,
checkIfAnyMovieHasRating,
findById,
filterByGenre,
checkMinMetascores,
getAllMoviesReleasedAtOrBeforeYear,
getRottenTomatoesScoreByMovie,
};