Created
December 29, 2022 21:57
-
-
Save brunohubner/97c45fd8328896efcb8cacb65343f96e to your computer and use it in GitHub Desktop.
This file contains 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 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