Skip to content

Instantly share code, notes, and snippets.

@jpcody
Created July 23, 2011 19:03
Show Gist options
  • Save jpcody/1101757 to your computer and use it in GitHub Desktop.
Save jpcody/1101757 to your computer and use it in GitHub Desktop.
var _generateGroupId = function randGen(){
// 2. newid is reset
var newId = Math.floor(Math.random() * 10);
if( _(myArray).include(newId) ){
// 1. you're sent back to the top of the function
randGen.apply( this );
} else {
myArray.push( newId );
// 3. a new id is explicitly returned. if you log here, you will get the new value
return newId;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment