-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathday19.js
34 lines (27 loc) · 912 Bytes
/
day19.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
import podcasts from "./data.js";
/* 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}
]
*/
function getFreePodcasts(data){
const freePodcasts = data.map(pod => {
return (!pod.paid) ? {
title: pod.title,
rating: pod.rating,
paid: pod.paid,
}: null
})
return freePodcasts.filter(val => val !== null)
}
console.log(getFreePodcasts(podcasts))