Created
December 8, 2016 17:44
-
-
Save rheajt/6c14924f142d3c88af708eec793b76df to your computer and use it in GitHub Desktop.
CODEGENERATOR
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
| function CODEGENERATOR() { | |
| var allCodes = []; // get all of the codes from all of the teacher sheets | |
| var letters = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p']; | |
| var codeLen = 7; | |
| var code = ''; | |
| for(var i = 0; i < codeLen; i++) { | |
| var randNum = Math.floor(Math.random() * 9); | |
| var randLetter = Math.floor(Math.random() * letters.length); | |
| var lon = Math.round(Math.random()); | |
| if(lon === 0) { | |
| code += letters[randLetter].toUpperCase(); | |
| } else { | |
| code += randNum; | |
| } | |
| } | |
| // if(allCodes.indexOf(code) === -1) { | |
| // // it is a unique code | |
| // } | |
| return code; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment