Skip to content

Instantly share code, notes, and snippets.

@ovaillancourt
Created August 16, 2012 18:32
Show Gist options
  • Save ovaillancourt/3372451 to your computer and use it in GitHub Desktop.
Save ovaillancourt/3372451 to your computer and use it in GitHub Desktop.
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