Last active
November 10, 2021 20:20
-
-
Save RuiGuilherme/e6fcf5a1e6f7458605e07a6d35e80efd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const isUsed = [1, 2, 10] // Coloca aq os números já usados | |
let genNumber = 1000 // Coloque aq a quantidade para gerar | |
for (let i = 1; i <= genNumber; i++) { | |
if (isUsed.indexOf(i) === -1) { | |
console.log(`XXX ${ i < 10 ? `00000${i}` : i < 100 ? `0000${i}` : i < 1000 ? `000${i}` : `00${i}` }`) | |
} | |
else { | |
// Assim evita a geração de um valor já em uso, e adiciona mais um valor a ser gerado. | |
genNumber++ | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment