Created
July 22, 2014 15:14
-
-
Save greduan/7af61605af70f7da984d to your computer and use it in GitHub Desktop.
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
// returns an array with a random chance of it's contents being more arrays or | |
// random strings | |
function randomArray(length) { | |
if (length == null) | |
length = 10; | |
var times = randTo.from1to(length); // amount of initial dirs/files | |
var result = []; | |
// make an array of times length | |
for (var i = 0; i <= times; i++) { | |
// random chance, hey it's a dir | |
if (randTo.from0to(1) === 1) | |
result[i] = []; | |
// not a dir | |
else | |
result[i] = randomString(); | |
} | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment