I guess this will be help to you.
* First you should create an array that includes number.
* Then you should create another array
* Then randomly pick a number from this array and place it to another
* After that remove the picked element from the number array.
function rand(n){
var numArr = new Array("0","1","2","3","4","5","6","7","8","9","10");
var pickArr = new Array();
var length=16;
for(var i=0;i<n;i++){
var num=numArr[Math.floor((Math.random()*length))];
pickArr[pickArr.length]=num
length--;
numArr.splice(findRank(numArr,num), 1);
}
return pickArr;
}
function findRank(seq,n){
var cnt=0;
var flag=true;
for(var i=0;i<seq.length&&flag;i++){
if(seq[i]==n)flag=false;
else cnt++;
}
return cnt;
}
r = nums[Math.floor(Math.random() * 7)]and append it to a cookie each time.Math.random()qualifies as truly random.