Created
August 21, 2014 02:55
-
-
Save darrenfu/e4622aba3ff958f74308 to your computer and use it in GitHub Desktop.
To generate a four digit number that doesn't repeat in each digit.
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 nums = new Array(); | |
for (var i=0;i<10;i++){ | |
nums.push(i); | |
} | |
var outputs = [0,0,0,0]; | |
for (var j=0;j<4;j++){ | |
var idx = (Math.random() * nums.length) | 0; | |
outputs[j] = nums[idx]; | |
nums.splice(idx,1); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment