Created
January 6, 2014 15:54
-
-
Save unknownuser88/8284844 to your computer and use it in GitHub Desktop.
2 random numbers
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 r = (function() { | |
function sample_range(t,n) { | |
var l = [],r = []; | |
for (var i = 1; i <= t; i++) r.push(i); | |
for (var i = 0; i < n; i++) l.push(r.splice(Math.random() * r.length, 1)); | |
return l; | |
} | |
return { | |
tworandom: function(n) { | |
return sample_range(n,3); | |
} | |
} | |
}()); | |
var a = r.tworandom(8); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment