-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgetFreePodcasts.js
94 lines (85 loc) · 2.34 KB
/
getFreePodcasts.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
/* Find Free Podcasts
We have a list of podcasts and need the ability to filter by only
podcasts which are free.
Write a function that takes in the podcast data and returns an new
array of only those podcasts which are free.
Additionally, your new array should return only
objects containing only the podcast title, rating, and whether or
not it is paid.
Expected output:
[
{title: "Scrimba Podcast", rating: 10, paid: false},
{title: "Something about Witches", rating: 8, paid: false},
{title: "Coding Corner", rating: 9, paid: false}
]
*/
let podcasts = [
{
id: 1,
title: "Scrimba Podcast",
duration: 50,
tags: ["education", "jobs", "technology"],
hosts: ["Alex Booker"],
rating: 10,
genre: "education",
paid: false
},
{
id: 2,
title: "Crime Fan",
duration: 150,
tags: ["crime", "entertainment", "mature"],
hosts: ["Bob Smith", "Camilla Lambert"],
genre: "true crime",
rating: 5,
paid: true
},
{
id: 3,
title: "Mythical Creatures",
duration: 99,
tags: ["entertainment", "general", "unicorns"],
hosts: ["Esmerelda Shelley", "Duke Dukington", "Felix the Cat"],
genre: "fantasy",
rating: 8,
paid: true
},
{
title: "Crime Crime Crime",
duration: 70,
tags: ["crime", "entertainment", "mature"],
hosts: ["Jessica Jones", "Humphrey Bogart", "Inspector Gadget"],
genre: "true crime",
rating: 6,
paid: true
},
{
title: "Something about Witches",
duration: 35,
tags: ["fantasy", "entertainment"],
hosts: ["Frewin Wyrm", "Evanora Highmore"],
genre: "fantasy",
rating: 8,
paid: false
},
{
title: "Coding Corner",
duration: 55,
tags: ["education", "jobs", "technology"],
hosts: ["Treasure Porth", "Guil Hernandez", "Tom Chant"],
genre: "education",
rating: 9,
paid: false
},
]
function getFreePodcasts(data) {
const freePodcasts = data.filter(({ paid }) => paid === false);
return freePodcasts.map(({ title, rating, paid }) => {
return {
title,
rating,
paid
}
});
}
console.log(getFreePodcasts(podcasts))