Last active
January 11, 2016 18:31
-
-
Save James1x0/52b58b1024f0efb786ff to your computer and use it in GitHub Desktop.
Neat little random array generator I came up with for a thought experiment.
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
function runAlongFolks ( init, iter, deviation ) { | |
var n = init || 150, | |
arr = []; | |
for ( var i = 0; i < iter; i++ ) { | |
var a = Math.floor(Math.random() * (deviation - (-deviation) + 1)) - deviation; | |
arr.push(n); | |
n += a; | |
} | |
return arr; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment