Skip to content

Instantly share code, notes, and snippets.

@kandebonfim
Last active February 4, 2016 18:05
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 kandebonfim/3b7700a51bbf381dd6f3 to your computer and use it in GitHub Desktop.
Save kandebonfim/3b7700a51bbf381dd6f3 to your computer and use it in GitHub Desktop.
A gist to generate an array with random numbers in CoffeeScript
random = (min, max) =>
Math.floor(Math.random() * (max - min) + min)
data = [1..100].map(() -> random(0,1000))
↑↑↑ Array length
// One line
data = [1..100].map(() -> Math.floor(Math.random() * (1000 - 0) + 0))
↑↑↑ Array length ↑max ↑min ↑min
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment