Skip to content

Instantly share code, notes, and snippets.

@carloscarucce
Created September 17, 2025 16:33
Show Gist options
  • Save carloscarucce/93be3a17c1fdc2f98b3704a9b55b6218 to your computer and use it in GitHub Desktop.
Save carloscarucce/93be3a17c1fdc2f98b3704a9b55b6218 to your computer and use it in GitHub Desktop.
Generate random numbers for lotto games
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