forked from gabischool/Week6_JS_Assignment
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharray_challenges.js
More file actions
71 lines (50 loc) · 2.17 KB
/
array_challenges.js
File metadata and controls
71 lines (50 loc) · 2.17 KB
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
/*
The Dataset: Movie Mania
You are managing a database for a **movie rental platform** called **Movie Mania**. The dataset is an array of objects, where each object represents a movie with the following properties:
- `title` (string): The title of the movie.
- `genre` (string): The genre of the movie (e.g., "Action", "Comedy", "Drama").
- `rating` (number): The average viewer rating (out of 10).
- `rented` (boolean): Whether the movie has been rented.
*/
const movies = [
{ title: "Fast & Furious 10", genre: "Action", rating: 7.5, rented: true },
{ title: "The Notebook", genre: "Drama", rating: 8.0, rented: false },
{ title: "Spider-Man: No Way Home", genre: "Action", rating: 8.7, rented: true },
{ title: "Superbad", genre: "Comedy", rating: 7.0, rented: false },
{ title: "The Dark Knight", genre: "Action", rating: 9.0, rented: true },
{ title: "The Intern", genre: "Comedy", rating: 7.4, rented: false }
];
/*
Task 1: Movie Titles and Ratings 🎥 (`.map`)
Your manager asks you to display a list of all movie titles and their ratings
for a promotional email campaign.
Steps:
1. Use `.map` to create a new array where each item is a string in this format:
"[title] - Rating: [rating]/10"
2. Log the resulting array.
Expected Output:
[
"Fast & Furious 10 - Rating: 7.5/10",
"The Notebook - Rating: 8.0/10",
"Spider-Man: No Way Home - Rating: 8.7/10",
"Superbad - Rating: 7.0/10",
"The Dark Knight - Rating: 9.0/10",
"The Intern - Rating: 7.4/10"
]
*/
// ✍️ Solve it here ✍️
/*
Task 2: Find Highly Rated Movies 🌟 (`.filter`)
Your customers have requested a list of **highly rated movies**
(movies with a rating of 8.0 or higher).
Steps:
1. Use `.filter` to create a new array containing only the movies with a rating >= 8.0.
2. Log the resulting array.
Expected Output:
[
{ title: "The Notebook", genre: "Drama", rating: 8.0, rented: false },
{ title: "Spider-Man: No Way Home", genre: "Action", rating: 8.7, rented: true },
{ title: "The Dark Knight", genre: "Action", rating: 9.0, rented: true }
]
*/
// ✍️ Solve it here ✍️