Generate a series of random integers between 1 and 10
Your code could potentially run forever - in theory, it could randomly pick the same number again and again and again. Probably won't, but the point is that the code may take a long time to run.

A simpler approach is to generate the numbers 1-10, and then shuffle them, Fisher-Yates style. Something like:

var numbers = new Array(10),
    shuffled = [];

// fill one array with the numbers 1-10
numbers = numbers.fill(1).map((_, i) =&gt; i + 1);

// shuffle by taking a random element from one array
// and pushing it to the other array
while (numbers.length) {
  let idx = numbers.length * Math.random() | 0; // floor trick
  shuffled.push(numbers[idx]);
  numbers.splice(idx, 1);
}

console.log(shuffled);


(The "floor trick" works by using bitwise OR. Now, bitwise OR zero does actually do anything, but all JavaScript bitwise operations interpret their operands to 32-bit integers, so it's like casting to an int, discarding decimals - i.e. it floors the number.)