Last active
November 28, 2016 23:50
-
-
Save MikeDigitize/403902a5fd69b23dbb8f to your computer and use it in GitHub Desktop.
Some coding challenges for the AO front end team who are learning JavaScript
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() { | |
| function getBalls() { | |
| var random = getRandom(1,59); | |
| if(!balls.includes(random)) { | |
| balls.push(random); | |
| } | |
| if(balls.length < 6) { | |
| return getBalls(); | |
| } | |
| else { | |
| return balls.sort((a,b) => a > b); | |
| } | |
| } | |
| var balls = []; | |
| return getBalls(); | |
| } | |
| function getRandom(min, max) { | |
| return Math.floor(Math.random() * (max - min + 1)) + min; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment