Created
September 17, 2025 16:33
-
-
Save carloscarucce/93be3a17c1fdc2f98b3704a9b55b6218 to your computer and use it in GitHub Desktop.
Generate random numbers for lotto games
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
function lotto(slots, max, min) { | |
slots = slots ?? 6; | |
max = max ?? 60; | |
min = min ?? 1; | |
const numbers = new Set(); | |
while (numbers.size < slots) { | |
const num = Math.floor(Math.random() * max) + min; | |
numbers.add(num); | |
} | |
return Array.from(numbers).sort((a,b) => a - b); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment