Skip to content

Instantly share code, notes, and snippets.

@brunohubner
Created December 29, 2022 21:57
Show Gist options
  • Save brunohubner/97c45fd8328896efcb8cacb65343f96e to your computer and use it in GitHub Desktop.
Save brunohubner/97c45fd8328896efcb8cacb65343f96e to your computer and use it in GitHub Desktop.
const maxNumbers = 60;
const defaultNumberListLength = 6;
const defaultBetNumber = 10;
function generateRandomNumber() {
return parseInt((Math.random() * maxNumbers)) + 1;
}
function generateRandomNumberList(numberListLength = defaultNumberListLength) {
const numbers = [];
do {
const randomNumber = generateRandomNumber();
if (!numbers.includes(randomNumber)) {
numbers.push(randomNumber);
}
} while (numbers.length < numberListLength);
return numbers;
}
function generateRandomBet(betNumber = defaultBetNumber) {
const bets = [];
for (let i = 0; i < betNumber; i++) {
bets.push(generateRandomNumberList());
}
return bets;
}
function main() {
generateRandomBet().forEach((bet, i) => console.log(`${i + 1}:`, bet, '\n'));
}
main();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment