I want to create a random number between 100 and 1000 , but i dont want The number to be duplicated ,like 101 or 111 or 909?

Im working on javascript problem code:

function randomNumberInt() {
return Math.floor(Math.random() * (1000 - 100 + 1) + 100);
}

Answer

Fill the array untill the length is 3 and then join.

function getRandomArbitrary(min, max) {
  return Math.floor(Math.random() * (max - min) + min) + 1;
}

function randomNumberInt() {
  const result = [];
  while (result.length !== 3) {
    let random = getRandomArbitrary(0, 9);
    if (!result.includes(random)) result.push(random);
    
    // To check if the first no is not zero
    if (result.length === 1 && random === 0) result.pop();
  }
  return parseInt( result.join("") );
}

const result = randomNumberInt();
console.log(result);