One approach would be to create an array to store existing selections, push selected elements to an array, check if the array contains the element and if the array storing values .length is greater than or equal to maximum range minus minimum range.
It is not clear from description at Question what should occur once all of the elements in the range have been returned?
var range = [10, 20];
var not = [];
function randomRange(range, n) {
if (not.length >= range[1] - range[0]) {
return "all numbers in range used"
}
var curr = [];
var res = [];
for (let i = range[0]; i < range[1]; i++) {
if (!not.some(function(num) {
return i == num
}) && not.length < range[1] - range[0]) {
curr.push(i)
}
}
for (let i = 0; i < n; i++) {
var j = curr.splice(Math.floor(Math.random() * curr.length), 1)[0];
res[i] = not[not.length] = j;
}
return res.filter(Boolean)
}
console.log(randomRange(range, 3));
console.log(randomRange(range, 3));
console.log(randomRange(range, 3));
console.log(randomRange(range, 3));
console.log(randomRange(range, 3));