Skip to content

Instantly share code, notes, and snippets.

@chapel
Last active December 13, 2015 17:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chapel/4947289 to your computer and use it in GitHub Desktop.
Save chapel/4947289 to your computer and use it in GitHub Desktop.
var albumIds = []
var albums = pin.photos.map(function(photo){
albumIds.push(photo.albumId)
return {
albumId: photo.albumId,
albumTitle: photo.albumTitle
};
})
// Alternative to avoid empty elements and duplicates
var alumbIds = []
var albums = []
pin.photos.forEach(function (photo) {
if (!!~albumIds.indexOf(photo.albumId) || !photo.albumId) return
albumIds.push(photo.albumId)
albums.push({
albumId: photo.albumId,
albumTitle: photo.albumTitle
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment