-
Notifications
You must be signed in to change notification settings - Fork 0
/
Movie.js
23 lines (22 loc) · 913 Bytes
/
Movie.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
class Movie{
constructor(title, studio, rating = "PG"){
//console.log("Creating a movie with the given details:", title, studio, rating)
this.title = title;
this.studio = studio;
this.rating = rating;
//console.log(`${this.title} is released by ${this.studio} and it has ${this.rating} ratings`);
}
static getPG(movies){
return movies.filter(movie => movie.rating === "PG")
}
}
const movie1 = new Movie("Casino Royale", "Eon Productions","PG:13");
const moviesArray = [
new Movie("Jumanji", "TriStar Pictures", "PG"),
new Movie("Finding Nemo", "Pixar Animation Studios", "G"),
new Movie("Frozen", "Walt Disney Pictures", "PG"),
new Movie("Scream", "Spyglass Media Group", "R"),
]
const pgMovies = Movie.getPG(moviesArray,movie1)
console.log("PG Rated Movies:");
pgMovies.forEach(movie => console.log(movie.title));