JSFiddle - React, Tailwind, and code Playground
HTML
<!DOCTYPE html>
<html lang="pt-br">
<head>
<meta charset="UTF-8">
<title>Gerador de numeros</title>
<script
src="https://code.jquery.com/jquery-3.3.1.min.js"
integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="
crossorigin="anonymous"></script>
<script>
function gerarNumeros(){
//Defina aqui a quantidade de numeros que serão gerados
let quantidadeNumeros = document.getElementById("quantidadenumeros").value
/* - - - - - - - - - - - - - - - - - - - - */
let arrayNumeros = []
let contador = 1
while(contador<= quantidadeNumeros){
//Gera um numero de 6 digitos
let numero = Math.floor(100000 + Math.random() * 900000)
//Se o numero aleoatóio NÃO está no array, adiciona ele e continua com o while, senão, gera outro
if(!arrayNumeros.includes(numero)){
arrayNumeros.push(numero)
contador++
}
}
console.log(arrayNumeros)
}
</script>
</head>
<body>
<h3>
Digite a Quantidade de Números para gerar:
</h3>
<input type="number" id="quantidadenumeros"><br/>
<input type="button" onclick="gerarNumeros();" id="botaoDownload" value="Download CSV">
</body>
</html>