Skip to content

Instantly share code, notes, and snippets.

@nvcexploder
Created September 19, 2012 23:18
Show Gist options
  • Save nvcexploder/3752978 to your computer and use it in GitHub Desktop.
Save nvcexploder/3752978 to your computer and use it in GitHub Desktop.
Recursive Call
internals.searchChildren = function ( id, toSearch, callback ) {
for( child in toSearch ) {
console.log('FOR LOOP');
if( id == toSearch[child].id ) {
//return the child
callback(null, toSearch[child].children);
break;
} else {
if( toSearch[child].children ) {
internals.searchChildren( id, toSearch[child], retrieveCallback );
}
}
}
console.log('************');
console.log('stopping now');
console.log('************');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment