Created
June 21, 2022 16:18
-
-
Save vessaro/3e42b434ff261034185e225331bf0b49 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 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)}`) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
publiquei no npm
repo: https://github.com/prescindivel/fezinha