Created
September 28, 2011 20:18
-
-
Save sandboxws/1249140 to your computer and use it in GitHub Desktop.
JavaScript function snippet
This file contains hidden or 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
| var getAlbumName = function(trackName) { | |
| var albumName = null; | |
| var albums = { | |
| theDarkSideOfTheMoon: { | |
| title: 'The Dark Side of the Moon', | |
| tracks: [ | |
| {title: 'Speak To Me'}, | |
| {title: 'Breathe'}, | |
| {title: 'On The Run'}, | |
| {title: 'Time'}, | |
| {title: 'The Great Gig In The Sky'}, | |
| {title: 'Money'}, | |
| {title: 'Us And Them'}, | |
| {title: 'Any Colour You Like'}, | |
| {title: 'Brain Damage'}, | |
| {title: 'Eclipse'} | |
| ] | |
| } | |
| }; | |
| for(_album in albums) { | |
| album = albums[_album]; | |
| tracks = album['tracks']; | |
| for(idx in tracks) { | |
| track = tracks[idx]; | |
| if(track['title'] == trackName) { | |
| albumName = album['title']; | |
| return albumName; | |
| } | |
| } | |
| } | |
| }; | |
| getAlbumName('Breathe'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment