Created
July 23, 2011 19:03
-
-
Save jpcody/1101757 to your computer and use it in GitHub Desktop.
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 _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