es6 => es5
<script>
function rand(min, max) {
for (var exclude = [], i = 2; i < arguments.length; ++i) exclude[i - 2] = arguments[i];
max += 1 - min - exclude.length;
var result = min +(Math.random() * max)|0;
return exclude.sort(function(a, b) {
return a - b
}).reduce(function(result, value) {
return result + (result >= value)
}, result)
};
for (var i=0; i<50; i++) {document.write(rand(1, 8, 1, 3, 5, 7)+", ")}
</script>