Skip to content

Instantly share code, notes, and snippets.

@greduan
Created July 22, 2014 15:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save greduan/7af61605af70f7da984d to your computer and use it in GitHub Desktop.
Save greduan/7af61605af70f7da984d to your computer and use it in GitHub Desktop.
// 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