Created
August 16, 2012 18:32
-
-
Save ovaillancourt/3372451 to your computer and use it in GitHub Desktop.
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 findMostRecent(folder){ | |
var mostRecent = null | |
var contentList = getFolderContentList(folder.path); | |
for(var i = 0; i < contentList.length; ++i){ | |
if(contentList[i].type === 'file' && | |
(mostRecent === null || contentList[i].date > mostRecent.date)){ | |
mostRecent = contentList[i]; | |
} | |
else if(contentList[i].type === 'folder'){ | |
var subMostRecent = findMostRecent(contentList[i]); //Recursion right there | |
if( (subMostRecent && mostRecent === null) || | |
(subMostRecent.date > mostRecent.date) ){ | |
mostRecent = subMostRecent; | |
} | |
} | |
} | |
return mostRecent; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment