Last active
November 20, 2015 11:38
-
-
Save bsitruk/0cff0bd69502b32c3471 to your computer and use it in GitHub Desktop.
Functional programming: Combining map with concatAll
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function() { | |
var movieLists = [ | |
{ | |
name: "New Releases", | |
videos: [ | |
{ | |
"id": 70111470, | |
"title": "Die Hard", | |
"boxart": "http://cdn-0.nflximg.com/images/2891/DieHard.jpg", | |
"uri": "http://api.netflix.com/catalog/titles/movies/70111470", | |
"rating": 4.0, | |
"bookmark": [] | |
}, | |
{ | |
"id": 654356453, | |
"title": "Bad Boys", | |
"boxart": "http://cdn-0.nflximg.com/images/2891/BadBoys.jpg", | |
"uri": "http://api.netflix.com/catalog/titles/movies/70111470", | |
"rating": 5.0, | |
"bookmark": [{ id:432534, time:65876586 }] | |
} | |
] | |
}, | |
{ | |
name: "Dramas", | |
videos: [ | |
{ | |
"id": 65432445, | |
"title": "The Chamber", | |
"boxart": "http://cdn-0.nflximg.com/images/2891/TheChamber.jpg", | |
"uri": "http://api.netflix.com/catalog/titles/movies/70111470", | |
"rating": 4.0, | |
"bookmark": [] | |
}, | |
{ | |
"id": 675465, | |
"title": "Fracture", | |
"boxart": "http://cdn-0.nflximg.com/images/2891/Fracture.jpg", | |
"uri": "http://api.netflix.com/catalog/titles/movies/70111470", | |
"rating": 5.0, | |
"bookmark": [{ id:432534, time:65876586 }] | |
} | |
] | |
} | |
]; | |
return movieLists.map(function(movie) { | |
return movie.videos.map(function(video) { | |
return video.id | |
}) | |
}).concatAll(); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment