Skip to content

Instantly share code, notes, and snippets.

@gtkatakura
Created June 30, 2016 01:40
Show Gist options
  • Save gtkatakura/175d45a600205130b763ec4a0a95562f to your computer and use it in GitHub Desktop.
Save gtkatakura/175d45a600205130b763ec4a0a95562f to your computer and use it in GitHub Desktop.
function identity(value) {
return value;
}
function createArray(length, transformation) {
transformation = transformation || identity;
var arr = [];
while (length != 0) {
arr.push(transformation(arr.length));
length--;
}
return arr;
}
function createRandomNumber() {
var max = 100;
var min = 1;
return Math.floor(Math.random() * (max - min)) + min;
}
function createRandomArray(length) {
return createArray(length, createRandomNumber);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment