Skip to content

Instantly share code, notes, and snippets.

@outsideris
Created April 21, 2015 12:43
Show Gist options
  • Save outsideris/48b94685c16e0ece8bea to your computer and use it in GitHub Desktop.
Save outsideris/48b94685c16e0ece8bea to your computer and use it in GitHub Desktop.
function createRandom(n, max) {
var r,
arr = [];
for (; arr.length < max;) {
r = Math.floor((Math.random() * 15) + 1);
if (r !== 8 && r !== 10 && r !== 14) {
var hasValue = false;
for (var i=0; i<arr.length;i++) {
if (arr[i] === r) {
hasValue = true;
}
}
if (!hasValue) {
arr.push(r);
}
}
}
return arr;
}
createRandom(15, 3);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment