Skip to content

Instantly share code, notes, and snippets.

@IanRamosC
Created November 18, 2016 13:58
Show Gist options
  • Save IanRamosC/df6edd5704ff5c12f0db1fab968cfaa0 to your computer and use it in GitHub Desktop.
Save IanRamosC/df6edd5704ff5c12f0db1fab968cfaa0 to your computer and use it in GitHub Desktop.
let generateRandom = _ => {
return (~~(Math.random() * 60)) + 1
}
let generateMegaSenaResult = _ => {
let result = [];
while (result.length < 6) {
let number = generateRandom();
if(result.indexOf(number) < 0) {
result.push(number);
}
}
return result.sort((a, b) => {
return a - b;
}).join(', ');
}
console.log(generateMegaSenaResult());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment