Created
April 2, 2012 20:00
-
-
Save soopercorp/2286836 to your computer and use it in GitHub Desktop.
cd-solution
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
/* | |
Task: | |
Fill the array ‘randomNumbers’ with 64 random numbers. | |
Make sure that there are no duplicate numbers in the array. | |
*/ | |
// You can’t change this function | |
function getRandomNumber(callback) { | |
var random = Math.floor( Math.random() * 128 ); | |
return setTimeout( function(){ callback(random); }, 1000); | |
} | |
var randomNumbers = []; | |
// Start your code below here | |
// ----------------------------------- | |
var ct = 0; | |
function rand(number) { | |
if(ct==64) | |
return; | |
if(randomNumbers.indexOf(number) == -1) { | |
randomNumbers.push(number); | |
ct++; | |
} | |
} | |
setInterval(getRandomNumber,0,rand); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment