var arr = [];
while (arr.length < 10) {
var n = Math.floor(Math.random() * 30) + 1;
if (arr.indexOf(n) == -1) {
arr.push(n);
}
}
// use Math.round() will give an uneven distribution!
function getRandomInt(min, max)
{
return Math.floor(Math.random() * (max - min + 1)) + min;
}
Find more questions by tags jQueryJavaScript