Skip to content

Instantly share code, notes, and snippets.

@vessaro
Created June 21, 2022 16:18
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vessaro/3e42b434ff261034185e225331bf0b49 to your computer and use it in GitHub Desktop.
Save vessaro/3e42b434ff261034185e225331bf0b49 to your computer and use it in GitHub Desktop.
🀞 πŸ€
const QUINA = {
size: 5,
max: 80,
}
const MEGA = {
size: 6,
max: 60,
}
const getRndInteger = (min, max) => {
return Math.floor(Math.random() * (max - min + 1)) + min
}
const draw = (lottery) => {
const bet = []
for (let index = 0; index < lottery.size; index++) {
let drawnNumber = getRndInteger(1, lottery.max)
while (bet.includes(drawnNumber)) {
drawnNumber = getRndInteger(1, lottery.max)
}
bet.push(drawnNumber)
}
return bet.sort((a, b) => a - b)
}
console.log(`Quina: ${draw(QUINA)}`)
console.log(`Mega: ${draw(MEGA)}`)
@prescindivel
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment