Created
June 30, 2016 01:40
-
-
Save gtkatakura/175d45a600205130b763ec4a0a95562f to your computer and use it in GitHub Desktop.
This file contains 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 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