<script>
function randomNumber(n, start, end) {
var i = 0,
arr = [];
for (; arr.length < n; i++) {
var num = Math.floor(Math.random() * (end - start)) + start;
if ($.inArray(num, arr) == -1) {
arr.push(num);
}
}
return arr.sort(function(a, b) {
return a > b
});
}
console.log(randomNumber(10, 0, 10));
</script>
时间: 2024-10-11 21:54:29